changeset 20569:0d4be103c734

revset: added _hexlist method to replace _list for %ln Now %ln expression goes through _hexlist and doesn't do any unnecesary processing anymore.
author Lucas Moscovicz <lmoscovicz@fb.com>
date Wed, 26 Feb 2014 17:15:55 -0800
parents d7eb839535d1
children c21e1e3ab915
files mercurial/revset.py
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Wed Feb 26 17:57:23 2014 -0600
+++ b/mercurial/revset.py	Wed Feb 26 17:15:55 2014 -0800
@@ -1589,6 +1589,16 @@
     s = subset.set()
     return baseset([r for r in ls if r in s])
 
+# for internal use
+def _hexlist(repo, subset, x):
+    s = getstring(x, "internal error")
+    if not s:
+        return baseset([])
+    cl = repo.changelog
+    ls = [cl.rev(node.bin(r)) for r in s.split('\0')]
+    s = subset.set()
+    return baseset([r for r in ls if r in s])
+
 symbols = {
     "adds": adds,
     "all": getall,
@@ -1657,6 +1667,7 @@
     "unstable": unstable,
     "_list": _list,
     "_intlist": _intlist,
+    "_hexlist": _hexlist,
 }
 
 # symbols which can't be used for a DoS attack for any given input
@@ -1728,6 +1739,7 @@
     "unstable",
     "_list",
     "_intlist",
+    "_hexlist",
 ])
 
 methods = {
@@ -2038,7 +2050,7 @@
         elif t == 's':
             return "_list('%s')" % "\0".join(s)
         elif t == 'n':
-            return "_list('%s')" % "\0".join(node.hex(a) for a in s)
+            return "_hexlist('%s')" % "\0".join(node.hex(a) for a in s)
         elif t == 'b':
             return "_list('%s')" % "\0".join(a.branch() for a in s)