revset: avoid demandimport bug
authorMatt Mackall <mpm@selenic.com>
Fri, 13 Apr 2012 15:32:49 -0500
changeset 16417 b4b0c6931e11
parent 16415 a232a1b5ae9b
child 16418 e5750c6716eb
revset: avoid demandimport bug Apparently the "import x as xy" doesn't manage to update xy in the current scope's dictionary after load, which causes nodemod.nullrev to do a huge amount of demandload magic in the inner loop.
mercurial/revset.py
--- a/mercurial/revset.py	Thu Apr 12 20:52:39 2012 -0500
+++ b/mercurial/revset.py	Fri Apr 13 15:32:49 2012 -0500
@@ -7,7 +7,7 @@
 
 import re
 import parser, util, error, discovery, hbisect, phases
-import node as nodemod
+import node
 import bookmarks as bookmarksmod
 import match as matchmod
 from i18n import _
@@ -18,7 +18,7 @@
     cut = followfirst and 1 or None
     cl = repo.changelog
     visit = list(revs)
-    seen = set([nodemod.nullrev])
+    seen = set([node.nullrev])
     while visit:
         for parent in cl.parentrevs(visit.pop(0))[:cut]:
             if parent not in seen:
@@ -31,7 +31,8 @@
     cut = followfirst and 1 or None
     cl = repo.changelog
     first = min(revs)
-    if first == nodemod.nullrev:
+    nullrev = node.nullrev
+    if first == nullrev:
         # Are there nodes with a null first parent and a non-null
         # second one? Maybe. Do we care? Probably not.
         for i in cl:
@@ -41,7 +42,7 @@
     seen = set(revs)
     for i in xrange(first + 1, len(cl)):
         for x in cl.parentrevs(i)[:cut]:
-            if x != nodemod.nullrev and x in seen:
+            if x != nullrev and x in seen:
                 seen.add(i)
                 yield i
                 break
@@ -724,7 +725,7 @@
     pat = getstring(x, _("modifies requires a pattern"))
     return checkstatus(repo, subset, pat, 0)
 
-def node(repo, subset, x):
+def node_(repo, subset, x):
     """``id(string)``
     Revision non-ambiguously specified by the given hex string prefix.
     """
@@ -1125,7 +1126,7 @@
     "grep": grep,
     "head": head,
     "heads": heads,
-    "id": node,
+    "id": node_,
     "keyword": keyword,
     "last": last,
     "limit": limit,
@@ -1399,7 +1400,7 @@
             parse(arg) # make sure syntax errors are confined
             return '(%s)' % arg
         elif c == 'n':
-            return quote(nodemod.hex(arg))
+            return quote(node.hex(arg))
         elif c == 'b':
             return quote(arg.branch())
 
@@ -1414,7 +1415,7 @@
         elif t == 's':
             return "_list('%s')" % "\0".join(s)
         elif t == 'n':
-            return "_list('%s')" % "\0".join(nodemod.hex(a) for a in s)
+            return "_list('%s')" % "\0".join(node.hex(a) for a in s)
         elif t == 'b':
             return "_list('%s')" % "\0".join(a.branch() for a in s)