revset: implement dagrange directly
authorBryan O'Sullivan <bryano@fb.com>
Fri, 01 Jun 2012 15:50:22 -0700
changeset 16861 76bcd3eac67e
parent 16860 e1aa1ed30030
child 16862 b6efeb27e733
revset: implement dagrange directly This is much faster than the older implementation (~8x).
mercurial/revset.py
--- a/mercurial/revset.py	Fri Jun 01 15:50:22 2012 -0700
+++ b/mercurial/revset.py	Fri Jun 01 15:50:22 2012 -0700
@@ -192,9 +192,15 @@
     return [x for x in r if x in s]
 
 def dagrange(repo, subset, x, y):
-    return andset(repo, subset,
-                  ('func', ('symbol', 'descendants'), x),
-                  ('func', ('symbol', 'ancestors'), y))
+    if subset:
+        r = range(len(repo))
+        m = getset(repo, r, x)
+        n = getset(repo, r, y)
+        cl = repo.changelog
+        xs = map(cl.rev, cl.nodesbetween(map(cl.node, m), map(cl.node, n))[0])
+        s = set(subset)
+        return [r for r in xs if r in s]
+    return []
 
 def andset(repo, subset, x, y):
     return getset(repo, getset(repo, subset, x), y)