[PATCH 08 of 13] revset: replace range(len(repo)) with revsubset(repo)
Bryan O'Sullivan
bos at serpentine.com
Fri Jun 1 17:52:06 CDT 2012
# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1338591022 25200
# Node ID 306cbeed89406db750345fad854f05a48b5a332f
# Parent 4b56ee070f13b26662ed848ed1c4cfaa6f4bf904
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
@@ -277,11 +277,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 []
@@ -296,7 +296,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]
@@ -339,7 +339,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:
@@ -350,7 +350,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)
@@ -476,7 +476,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())
@@ -527,7 +527,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]
@@ -586,7 +586,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)
@@ -839,7 +839,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):
@@ -857,14 +857,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:
@@ -884,7 +884,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:
@@ -950,7 +950,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]
@@ -968,7 +968,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]
@@ -982,7 +982,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]
@@ -1113,7 +1113,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:
@@ -1200,7 +1200,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