[PATCH 1 of 2] extensions: add revset support to most extensions

Will Maier willmaier at ml1.net
Sat Nov 13 13:06:12 CST 2010


# HG changeset patch
# User Will Maier <willmaier at ml1.net>
# Date 1289478964 21600
# Node ID 612f4471636dc602e5c1196bd3ad6fddb3edd6a6
# Parent  91cbba199d8b1f1160f4b972fd15e1076b7edb5a
extensions: add revset support to most extensions

diff --git a/hgext/bookmarks.py b/hgext/bookmarks.py
--- a/hgext/bookmarks.py
+++ b/hgext/bookmarks.py
@@ -31,7 +31,7 @@ branching.
 from mercurial.i18n import _
 from mercurial.node import nullid, nullrev, bin, hex, short
 from mercurial import util, commands, repair, extensions, pushkey, hg, url
-from mercurial import revset
+from mercurial import cmdutil, revset
 import os
 
 def write(repo):
@@ -151,7 +151,7 @@ def bookmark(ui, repo, mark=None, rev=No
             raise util.Abort(
                 _("a bookmark cannot have the name of an existing branch"))
         if rev:
-            marks[mark] = repo.lookup(rev)
+            marks[mark] = cmdutil.revsingle(repo, rev).node()
         else:
             marks[mark] = repo.changectx('.').node()
         setcurrent(repo, mark)
diff --git a/hgext/children.py b/hgext/children.py
--- a/hgext/children.py
+++ b/hgext/children.py
@@ -24,11 +24,11 @@ def children(ui, repo, file_=None, **opt
     file was last changed (after the working directory revision or the
     argument to --rev if given) is printed.
     """
-    rev = opts.get('rev')
+    rev = cmdutil.revsingle(repo, opts.get('rev'))
     if file_:
-        ctx = repo.filectx(file_, changeid=rev)
+        ctx = repo.filectx(file_, changeid=rev.rev())
     else:
-        ctx = repo[rev]
+        ctx = rev
 
     displayer = cmdutil.show_changeset(ui, repo, opts)
     for cctx in ctx.children():
diff --git a/hgext/extdiff.py b/hgext/extdiff.py
--- a/hgext/extdiff.py
+++ b/hgext/extdiff.py
@@ -121,7 +121,7 @@ def dodiff(ui, repo, diffcmd, diffopts, 
         msg = _('cannot specify --rev and --change at the same time')
         raise util.Abort(msg)
     elif change:
-        node2 = repo.lookup(change)
+        node2 = cmdutil.revsingle(repo, change).node()
         node1a, node1b = repo.changelog.parents(node2)
     else:
         node1a, node2 = cmdutil.revpair(repo, revs)
diff --git a/hgext/fetch.py b/hgext/fetch.py
--- a/hgext/fetch.py
+++ b/hgext/fetch.py
@@ -70,7 +70,7 @@ def fetch(ui, repo, source='default', **
         revs = None
         if opts['rev']:
             try:
-                revs = [other.lookup(rev) for rev in opts['rev']]
+                revs = [cmdutil.revsingle(other, rev).node() for rev in opts['rev']]
             except error.CapabilityError:
                 err = _("Other repository doesn't support revision lookup, "
                         "so a rev cannot be specified.")
diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -6,7 +6,7 @@
 '''commands to sign and verify changesets'''
 
 import os, tempfile, binascii
-from mercurial import util, commands, match
+from mercurial import cmdutil, util, commands, match
 from mercurial import node as hgnode
 from mercurial.i18n import _
 
@@ -162,7 +162,7 @@ def sigs(ui, repo):
 def check(ui, repo, rev):
     """verify all the signatures there may be for a particular revision"""
     mygpg = newgpg(ui)
-    rev = repo.lookup(rev)
+    rev = cmdutil.revsingle(repo, rev).node()
     hexrev = hgnode.hex(rev)
     keys = []
 
@@ -209,7 +209,7 @@ def sign(ui, repo, *revs, **opts):
         opts['date'] = util.parsedate(date)
 
     if revs:
-        nodes = [repo.lookup(n) for n in revs]
+        nodes = [cmdutil.revsingle(repo, n).node() for n in revs]
     else:
         nodes = [node for node in repo.dirstate.parents()
                  if node != hgnode.nullid]
diff --git a/hgext/hgk.py b/hgext/hgk.py
--- a/hgext/hgk.py
+++ b/hgext/hgk.py
@@ -35,7 +35,7 @@ vdiff on hovered and selected revisions.
 '''
 
 import os
-from mercurial import commands, util, patch, revlog, cmdutil
+from mercurial import cmdutil, commands, util, patch, revlog, cmdutil
 from mercurial.node import nullid, nullrev, short
 from mercurial.i18n import _
 
@@ -43,8 +43,8 @@ def difftree(ui, repo, node1=None, node2
     """diff trees from two commits"""
     def __difftree(repo, node1, node2, files=[]):
         assert node2 is not None
-        mmap = repo[node1].manifest()
-        mmap2 = repo[node2].manifest()
+        mmap = cmdutil.revsingle(repo, node1).manifest()
+        mmap2 = cmdutil.revsingle(repo, node2).manifest()
         m = cmdutil.match(repo, files)
         modified, added, removed  = repo.status(node1, node2, m)[:3]
         empty = short(nullid)
@@ -72,9 +72,9 @@ def difftree(ui, repo, node1=None, node2
                     node2 = None
             except EOFError:
                 break
-        node1 = repo.lookup(node1)
+        node1 = cmdutil.revsingle(repo, node1).node()
         if node2:
-            node2 = repo.lookup(node2)
+            node2 = cmdutil.revsingle(repo, node2).node()
         else:
             node2 = node1
             node1 = repo.changelog.parents(node1)[0]
@@ -121,8 +121,8 @@ def catcommit(ui, repo, n, prefix, ctx=N
 
 def base(ui, repo, node1, node2):
     """output common ancestor information"""
-    node1 = repo.lookup(node1)
-    node2 = repo.lookup(node2)
+    node1 = cmdutil.revsingle(repo, node1).node()
+    node2 = cmdutil.revsingle(repo, node2).node()
     n = repo.changelog.ancestor(node1, node2)
     ui.write(short(n) + "\n")
 
@@ -149,7 +149,7 @@ def catfile(ui, repo, type=None, r=None,
         if type != "commit":
             ui.warn(_("aborting hg cat-file only understands commits\n"))
             return 1
-        n = repo.lookup(r)
+        n = cmdutil.revsingle(repo, r).node()
         catcommit(ui, repo, n, prefix)
         if opts['stdin']:
             try:
@@ -212,11 +212,11 @@ def revtree(ui, args, repo, full="tree",
     # want us to stop on
     for i, arg in enumerate(args):
         if arg.startswith('^'):
-            s = repo.lookup(arg[1:])
+            s = cmdutil.revrange(arg[1:])
             stop_sha1.append(s)
             want_sha1.append(s)
         elif arg != 'HEAD':
-            want_sha1.append(repo.lookup(arg))
+            want_sha1.append(cmdutil.revsingle(repo, arg).node())
 
     # calculate the graph for the supplied commits
     for i, n in enumerate(want_sha1):
@@ -275,7 +275,7 @@ def revparse(ui, repo, *revs, **opts):
     def revstr(rev):
         if rev == 'HEAD':
             rev = 'tip'
-        return revlog.hex(repo.lookup(rev))
+        return revlog.hex(cmdutil.revsingle(repo, rev).node())
 
     for r in revs:
         revrange = r.split(':', 1)
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -2432,7 +2432,7 @@ def restore(ui, repo, rev, **opts):
     """restore the queue state saved by a revision (DEPRECATED)
 
     This command is deprecated, use :hg:`rebase` instead."""
-    rev = repo.lookup(rev)
+    rev = cmdutil.revsingle(repo, rev).node()
     q = repo.mq
     q.restore(repo, rev, delete=opts.get('delete'),
               qupdate=opts.get('update'))
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -236,7 +236,7 @@ def patchbomb(ui, repo, *revs, **opts):
         dest, branches = hg.parseurl(dest)
         revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
         if revs:
-            revs = [repo.lookup(rev) for rev in revs]
+            revs = [cmdutil.revsingle(repo, rev).node() for rev in revs]
         other = hg.repository(hg.remoteui(repo, opts), dest)
         ui.status(_('comparing with %s\n') % url.hidepassword(dest))
         o = discovery.findoutgoing(repo, other)


More information about the Mercurial-devel mailing list