Patchwork [2,of,2] revset: changed revsets to use spanset

login
register
mail settings
Submitter Lucas Moscovicz
Date Feb. 18, 2014, 9:03 p.m.
Message ID <eb7b699b7bc1f77d3d14.1392757439@dev1037.prn2.facebook.com>
Download mbox | patch
Permalink /patch/3689/
State Accepted
Commit 9ad6dae67845b3d106f233b16bdc207389ee9d19
Headers show

Comments

Lucas Moscovicz - Feb. 18, 2014, 9:03 p.m.
# HG changeset patch
# User Lucas Moscovicz <lmoscovicz@fb.com>
# Date 1391451315 28800
#      Mon Feb 03 10:15:15 2014 -0800
# Node ID eb7b699b7bc1f77d3d14fbdb248720cd1925a489
# Parent  cdfd878d0fa54f86ac77f1e5ae0c33f26a8e7c0e
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)
Matt Mackall - Feb. 18, 2014, 9:39 p.m.
On Tue, 2014-02-18 at 13:03 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@fb.com>
> # Date 1391451315 28800
> #      Mon Feb 03 10:15:15 2014 -0800
> # Node ID eb7b699b7bc1f77d3d14fbdb248720cd1925a489
> # Parent  cdfd878d0fa54f86ac77f1e5ae0c33f26a8e7c0e
> revset: changed revsets to use spanset

Excellent, queued for default.
Matt Mackall - Feb. 18, 2014, 9:51 p.m.
On Tue, 2014-02-18 at 13:03 -0800, Lucas Moscovicz wrote:
> # HG changeset patch
> # User Lucas Moscovicz <lmoscovicz@fb.com>
> # Date 1391451315 28800
> #      Mon Feb 03 10:15:15 2014 -0800
> # Node ID eb7b699b7bc1f77d3d14fbdb248720cd1925a489
> # Parent  cdfd878d0fa54f86ac77f1e5ae0c33f26a8e7c0e
> revset: changed revsets to use spanset

Excellent, queued for default.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2558,7 +2558,7 @@ 
         if newtree != tree:
             ui.note(revset.prettyformat(newtree), "\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]'))
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -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:
@@ -1068,9 +1067,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)
@@ -1120,7 +1119,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
 
@@ -1138,7 +1137,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
 
@@ -1152,7 +1151,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
 
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -524,7 +524,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)