[PATCH 1 of 5 RFC] revset: add getrev utility
Matt Harbison
matt_harbison at yahoo.com
Mon May 14 00:29:59 CDT 2012
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1336879722 14400
# Node ID f4e3289b34bc781abb648148e6e328285ecc4301
# Parent 0a176990243c9b4753039867164cfed560806fb7
revset: add getrev utility
This converts a local id, short hex string, or partially matching hex string to
the full 40 character changeset hash. It also verifies that the revision
exists, raising RepoLookupError if it doesn't.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -12,6 +12,7 @@
import match as matchmod
from i18n import _
import encoding
+import binascii
def _revancestors(repo, revs, followfirst):
"""Like revlog.ancestors(), but supports followfirst."""
@@ -156,6 +157,11 @@
raise error.ParseError(_("missing argument"))
return methods[x[0]](repo, subset, *x[1:])
+def getrev(repo, x, err):
+ s = getstring(x, err)
+ node = repo.lookup(s)
+ return binascii.hexlify(node)
+
# operator methods
def stringset(repo, subset, x):
More information about the Mercurial-devel
mailing list