[PATCH 2 of 7] revset: replace range(len(repo)) with revsubset(repo)

Bryan O'Sullivan bos at serpentine.com
Mon Jun 4 17:25:08 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1338848634 25200
# Node ID a0bc9dbfe011f8cd3e12d7fbf409adad4fd89ee1
# Parent  4f118bc8e20a571cf283695269a625d013f19eb4
revset: replace range(len(repo)) with revsubset(repo)

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -275,11 +275,11 @@ def symbolset(repo, subset, x):
 def rangeset(repo, subset, x, y):
     m = getset(repo, subset, x)
     if not m:
-        m = getset(repo, range(len(repo)), x)
+        m = getset(repo, revsubset(repo), x)
 
     n = getset(repo, subset, y)
     if not n:
-        n = getset(repo, range(len(repo)), y)
+        n = getset(repo, revsubset(repo), y)
 
     if not m or not n:
         return []
@@ -294,7 +294,7 @@ def rangeset(repo, subset, x, y):
 
 def dagrange(repo, subset, x, y):
     if subset:
-        r = range(len(repo))
+        r = revsubset(repo)
         xs = _revsbetween(repo, getset(repo, r, x), getset(repo, r, y))
         s = set(subset)
         return [r for r in xs if r in s]
@@ -337,7 +337,7 @@ def ancestor(repo, subset, x):
     """
     # i18n: "ancestor" is a keyword
     l = getargs(x, 2, 2, _("ancestor requires two arguments"))
-    r = range(len(repo))
+    r = revsubset(repo)
     a = getset(repo, r, l[0])
     b = getset(repo, r, l[1])
     if len(a) != 1 or len(b) != 1:
@@ -348,7 +348,7 @@ def ancestor(repo, subset, x):
     return [r for r in an if r in subset]
 
 def _ancestors(repo, subset, x, followfirst=False):
-    args = getset(repo, range(len(repo)), x)
+    args = getset(repo, revsubset(repo), x)
     if not args:
         return []
     s = set(_revancestors(repo, args, followfirst)) | set(args)
@@ -474,7 +474,7 @@ def branch(repo, subset, x):
         else:
             return [r for r in subset if matcher(repo[r].branch())]
 
-    s = getset(repo, range(len(repo)), x)
+    s = getset(repo, revsubset(repo), x)
     b = set()
     for r in s:
         b.add(repo[r].branch())
@@ -525,7 +525,7 @@ def children(repo, subset, x):
     """``children(set)``
     Child changesets of changesets in set.
     """
-    s = set(getset(repo, range(len(repo)), x))
+    s = set(getset(repo, revsubset(repo), x))
     cs = _children(repo, subset, s)
     return [r for r in subset if r in cs]
 
@@ -584,7 +584,7 @@ def desc(repo, subset, x):
     return l
 
 def _descendants(repo, subset, x, followfirst=False):
-    args = getset(repo, range(len(repo)), x)
+    args = getset(repo, revsubset(repo), x)
     if not args:
         return []
     s = set(_revdescendants(repo, args, followfirst)) | set(args)
@@ -837,7 +837,7 @@ def limit(repo, subset, x):
         # i18n: "limit" is a keyword
         raise error.ParseError(_("limit expects a number"))
     ss = set(subset)
-    os = getset(repo, range(len(repo)), l[0])[:lim]
+    os = getset(repo, revsubset(repo), l[0])[:lim]
     return [r for r in os if r in ss]
 
 def last(repo, subset, x):
@@ -855,14 +855,14 @@ def last(repo, subset, x):
         # i18n: "last" is a keyword
         raise error.ParseError(_("last expects a number"))
     ss = set(subset)
-    os = getset(repo, range(len(repo)), l[0])[-lim:]
+    os = getset(repo, revsubset(repo), l[0])[-lim:]
     return [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, range(len(repo)), x)
+    os = getset(repo, revsubset(repo), x)
     if os:
         m = max(os)
         if m in subset:
@@ -882,7 +882,7 @@ def minrev(repo, subset, x):
     """``min(set)``
     Changeset with lowest revision number in set.
     """
-    os = getset(repo, range(len(repo)), x)
+    os = getset(repo, revsubset(repo), x)
     if os:
         m = min(os)
         if m in subset:
@@ -948,7 +948,7 @@ def p1(repo, subset, x):
 
     ps = set()
     cl = repo.changelog
-    for r in getset(repo, range(len(repo)), x):
+    for r in getset(repo, revsubset(repo), x):
         ps.add(cl.parentrevs(r)[0])
     return [r for r in subset if r in ps]
 
@@ -966,7 +966,7 @@ def p2(repo, subset, x):
 
     ps = set()
     cl = repo.changelog
-    for r in getset(repo, range(len(repo)), x):
+    for r in getset(repo, revsubset(repo), x):
         ps.add(cl.parentrevs(r)[1])
     return [r for r in subset if r in ps]
 
@@ -980,7 +980,7 @@ def parents(repo, subset, x):
 
     ps = set()
     cl = repo.changelog
-    for r in getset(repo, range(len(repo)), x):
+    for r in getset(repo, revsubset(repo), x):
         ps.update(cl.parentrevs(r))
     return [r for r in subset if r in ps]
 
@@ -1111,7 +1111,7 @@ def matching(repo, subset, x):
     """
     l = getargs(x, 1, 2, _("matching takes 1 or 2 arguments"))
 
-    revs = getset(repo, xrange(len(repo)), l[0])
+    revs = getset(repo, revsubset(repo), l[0])
 
     fieldlist = ['metadata']
     if len(l) > 1:
@@ -1198,7 +1198,7 @@ def roots(repo, subset, x):
     """``roots(set)``
     Changesets in set with no parent changeset in set.
     """
-    s = set(getset(repo, xrange(len(repo)), x))
+    s = set(getset(repo, revsubset(repo), x))
     subset = [r for r in subset if r in s]
     cs = _children(repo, subset, s)
     return [r for r in subset if r not in cs]


More information about the Mercurial-devel mailing list