changeset 20526:9ad6dae67845

revset: changed revsets to use spanset Performance Benchmarking: $ hg perfrevset "first(all())" ! wall 0.304936 comb 0.300000 user 0.280000 sys 0.020000 (best of 33) $ ./hg perfrevset "first(all())" ! wall 0.175640 comb 0.180000 user 0.160000 sys 0.020000 (best of 56)
author Lucas Moscovicz <lmoscovicz@fb.com>
date Mon, 03 Feb 2014 10:15:15 -0800
parents aa73a6327df4
children bde426f18e0a
files mercurial/commands.py mercurial/revset.py mercurial/scmutil.py
diffstat 3 files changed, 22 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Feb 18 11:38:03 2014 -0800
+++ b/mercurial/commands.py	Mon Feb 03 10:15:15 2014 -0800
@@ -2567,7 +2567,7 @@
             weight, optimizedtree = revset.optimize(newtree, True)
             ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
     func = revset.match(ui, expr)
-    for c in func(repo, revset.baseset(range(len(repo)))):
+    for c in func(repo, revset.spanset(repo)):
         ui.write("%s\n" % c)
 
 @command('debugsetparents', [], _('REV1 [REV2]'))
--- a/mercurial/revset.py	Tue Feb 18 11:38:03 2014 -0800
+++ b/mercurial/revset.py	Mon Feb 03 10:15:15 2014 -0800
@@ -232,14 +232,13 @@
     m, n = m[0], n[-1]
 
     if m < n:
-        r = range(m, n + 1)
+        r = spanset(repo, m, n + 1)
     else:
-        r = range(m, n - 1, -1)
-    s = subset.set()
-    return baseset([x for x in r if x in s])
+        r = spanset(repo, m, n - 1)
+    return r & subset
 
 def dagrange(repo, subset, x, y):
-    r = baseset(repo)
+    r = spanset(repo)
     xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
     s = subset.set()
     return baseset([r for r in xs if r in s])
@@ -287,7 +286,7 @@
     """
     # i18n: "ancestor" is a keyword
     l = getlist(x)
-    rl = baseset(repo)
+    rl = spanset(repo)
     anc = None
 
     # (getset(repo, rl, i) for i in l) generates a list of lists
@@ -306,7 +305,7 @@
     return baseset([])
 
 def _ancestors(repo, subset, x, followfirst=False):
-    args = getset(repo, baseset(repo), x)
+    args = getset(repo, spanset(repo), x)
     if not args:
         return baseset([])
     s = set(_revancestors(repo, args, followfirst)) | set(args)
@@ -433,7 +432,7 @@
         else:
             return lazyset(subset, lambda r: matcher(repo[r].branch()))
 
-    s = getset(repo, baseset(repo), x)
+    s = getset(repo, spanset(repo), x)
     b = set()
     for r in s:
         b.add(repo[r].branch())
@@ -596,11 +595,11 @@
     return lazyset(subset, matches)
 
 def _descendants(repo, subset, x, followfirst=False):
-    args = getset(repo, baseset(repo), x)
+    args = getset(repo, spanset(repo), x)
     if not args:
         return baseset([])
     s = set(_revdescendants(repo, args, followfirst)) | set(args)
-    return baseset([r for r in subset if r in s])
+    return subset & s
 
 def descendants(repo, subset, x):
     """``descendants(set)``
@@ -620,9 +619,9 @@
     is the same as passing all().
     """
     if x is not None:
-        args = getset(repo, baseset(repo), x).set()
+        args = getset(repo, spanset(repo), x).set()
     else:
-        args = getall(repo, baseset(repo), x).set()
+        args = getall(repo, spanset(repo), x).set()
 
     dests = set()
 
@@ -943,7 +942,7 @@
         # i18n: "limit" is a keyword
         raise error.ParseError(_("limit expects a number"))
     ss = subset.set()
-    os = getset(repo, baseset(repo), l[0])
+    os = getset(repo, spanset(repo), l[0])
     bs = baseset([])
     it = iter(os)
     for x in xrange(lim):
@@ -970,14 +969,14 @@
         # i18n: "last" is a keyword
         raise error.ParseError(_("last expects a number"))
     ss = subset.set()
-    os = getset(repo, baseset(repo), l[0])[-lim:]
+    os = getset(repo, spanset(repo), l[0])[-lim:]
     return baseset([r for r in os if r in ss])
 
 def maxrev(repo, subset, x):
     """``max(set)``
     Changeset with highest revision number in set.
     """
-    os = getset(repo, baseset(repo), x)
+    os = getset(repo, spanset(repo), x)
     if os:
         m = max(os)
         if m in subset:
@@ -1014,7 +1013,7 @@
     """``min(set)``
     Changeset with lowest revision number in set.
     """
-    os = getset(repo, baseset(repo), x)
+    os = getset(repo, spanset(repo), x)
     if os:
         m = min(os)
         if m in subset:
@@ -1078,9 +1077,9 @@
     for the first operation is selected.
     """
     if x is not None:
-        args = getset(repo, baseset(repo), x).set()
+        args = getset(repo, spanset(repo), x).set()
     else:
-        args = getall(repo, baseset(repo), x).set()
+        args = getall(repo, spanset(repo), x).set()
 
     def _firstsrc(rev):
         src = _getrevsource(repo, rev)
@@ -1130,7 +1129,7 @@
 
     ps = set()
     cl = repo.changelog
-    for r in getset(repo, baseset(repo), x):
+    for r in getset(repo, spanset(repo), x):
         ps.add(cl.parentrevs(r)[0])
     return subset & ps
 
@@ -1148,7 +1147,7 @@
 
     ps = set()
     cl = repo.changelog
-    for r in getset(repo, baseset(repo), x):
+    for r in getset(repo, spanset(repo), x):
         ps.add(cl.parentrevs(r)[1])
     return subset & ps
 
@@ -1162,7 +1161,7 @@
 
     ps = set()
     cl = repo.changelog
-    for r in getset(repo, baseset(repo), x):
+    for r in getset(repo, spanset(repo), x):
         ps.update(cl.parentrevs(r))
     return subset & ps
 
--- a/mercurial/scmutil.py	Tue Feb 18 11:38:03 2014 -0800
+++ b/mercurial/scmutil.py	Mon Feb 03 10:15:15 2014 -0800
@@ -534,7 +534,7 @@
 
         # fall through to new-style queries if old-style fails
         m = revset.match(repo.ui, spec)
-        dl = [r for r in m(repo, revset.baseset(repo)) if r not in seen]
+        dl = [r for r in m(repo, revset.spanset(repo)) if r not in seen]
         l.extend(dl)
         seen.update(dl)