comparison mercurial/commands.py @ 13970:d13913355390

move opener from util to scmutil
author Adrian Buehlmann <adrian@cadifra.com>
date Wed, 20 Apr 2011 19:54:57 +0200
parents ac1c75a7c6b5
children d1f4e7fd970a
comparison
equal deleted inserted replaced
13969:336bb8b53ad0 13970:d13913355390
7 7
8 from node import hex, bin, nullid, nullrev, short 8 from node import hex, bin, nullid, nullrev, short
9 from lock import release 9 from lock import release
10 from i18n import _, gettext 10 from i18n import _, gettext
11 import os, re, sys, difflib, time, tempfile 11 import os, re, sys, difflib, time, tempfile
12 import hg, util, revlog, extensions, copies, error, bookmarks 12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks
13 import patch, help, mdiff, url, encoding, templatekw, discovery 13 import patch, help, mdiff, url, encoding, templatekw, discovery
14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server 14 import archival, changegroup, cmdutil, sshserver, hbisect, hgweb, hgweb.server
15 import merge as mergemod 15 import merge as mergemod
16 import minirst, revset, templatefilters 16 import minirst, revset, templatefilters
17 import dagparser 17 import dagparser
973 973
974 def debugancestor(ui, repo, *args): 974 def debugancestor(ui, repo, *args):
975 """find the ancestor revision of two revisions in a given index""" 975 """find the ancestor revision of two revisions in a given index"""
976 if len(args) == 3: 976 if len(args) == 3:
977 index, rev1, rev2 = args 977 index, rev1, rev2 = args
978 r = revlog.revlog(util.opener(os.getcwd(), audit=False), index) 978 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
979 lookup = r.lookup 979 lookup = r.lookup
980 elif len(args) == 2: 980 elif len(args) == 2:
981 if not repo: 981 if not repo:
982 raise util.Abort(_("there is no Mercurial repository here " 982 raise util.Abort(_("there is no Mercurial repository here "
983 "(.hg not found)")) 983 "(.hg not found)"))
1391 Otherwise, the changelog DAG of the current repo is emitted. 1391 Otherwise, the changelog DAG of the current repo is emitted.
1392 """ 1392 """
1393 spaces = opts.get('spaces') 1393 spaces = opts.get('spaces')
1394 dots = opts.get('dots') 1394 dots = opts.get('dots')
1395 if file_: 1395 if file_:
1396 rlog = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) 1396 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1397 revs = set((int(r) for r in revs)) 1397 revs = set((int(r) for r in revs))
1398 def events(): 1398 def events():
1399 for r in rlog: 1399 for r in rlog:
1400 yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1))) 1400 yield 'n', (r, list(set(p for p in rlog.parentrevs(r) if p != -1)))
1401 if r in revs: 1401 if r in revs:
1441 if repo: 1441 if repo:
1442 filelog = repo.file(file_) 1442 filelog = repo.file(file_)
1443 if len(filelog): 1443 if len(filelog):
1444 r = filelog 1444 r = filelog
1445 if not r: 1445 if not r:
1446 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i") 1446 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
1447 file_[:-2] + ".i")
1447 try: 1448 try:
1448 ui.write(r.revision(r.lookup(rev))) 1449 ui.write(r.revision(r.lookup(rev)))
1449 except KeyError: 1450 except KeyError:
1450 raise util.Abort(_('invalid revision identifier %s') % rev) 1451 raise util.Abort(_('invalid revision identifier %s') % rev)
1451 1452
1480 format = opts.get('format', 0) 1481 format = opts.get('format', 0)
1481 if format not in (0, 1): 1482 if format not in (0, 1):
1482 raise util.Abort(_("unknown format %d") % format) 1483 raise util.Abort(_("unknown format %d") % format)
1483 1484
1484 if not r: 1485 if not r:
1485 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) 1486 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1486 1487
1487 if format == 0: 1488 if format == 0:
1488 ui.write(" rev offset length base linkrev" 1489 ui.write(" rev offset length base linkrev"
1489 " nodeid p1 p2\n") 1490 " nodeid p1 p2\n")
1490 elif format == 1: 1491 elif format == 1:
1513 if repo: 1514 if repo:
1514 filelog = repo.file(file_) 1515 filelog = repo.file(file_)
1515 if len(filelog): 1516 if len(filelog):
1516 r = filelog 1517 r = filelog
1517 if not r: 1518 if not r:
1518 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_) 1519 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1519 ui.write("digraph G {\n") 1520 ui.write("digraph G {\n")
1520 for i in r: 1521 for i in r:
1521 node = r.node(i) 1522 node = r.node(i)
1522 pp = r.parents(node) 1523 pp = r.parents(node)
1523 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i)) 1524 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))