[PATCH 1 of 2 v3] revlog: ancestors(*revs) becomes ancestors(revs)
Bryan O'Sullivan
bos at serpentine.com
Fri Jun 1 21:03:41 UTC 2012
# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1338579438 25200
# Node ID 06f90e0125bf8b49447ee2383f90f85ee2ebe032
# Parent 3e3661a09635758712e3005199b6f8c6dcffffa7
revlog: ancestors(*revs) becomes ancestors(revs)
Accepting a variable number of arguments as the old API did is
deeply ugly, particularly as it means the API can't be extended
with new arguments. Partly as a result, we have at least three
different implementations of the same ancestors algorithm (!?).
Most callers were forced to call ancestors(*somelist), adding to
both inefficiency and ugliness.
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -74,7 +74,7 @@ def perftags(ui, repo):
def perfancestors(ui, repo):
heads = repo.changelog.headrevs()
def d():
- for a in repo.changelog.ancestors(*heads):
+ for a in repo.changelog.ancestors(heads):
pass
timer(d)
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -224,7 +224,7 @@ def rebase(ui, repo, **opts):
else:
originalwd, target, state = result
if collapsef:
- targetancestors = set(repo.changelog.ancestors(target))
+ targetancestors = set(repo.changelog.ancestors([target]))
targetancestors.add(target)
external = checkexternal(repo, state, targetancestors)
@@ -243,7 +243,7 @@ def rebase(ui, repo, **opts):
# Rebase
if not targetancestors:
- targetancestors = set(repo.changelog.ancestors(target))
+ targetancestors = set(repo.changelog.ancestors([target]))
targetancestors.add(target)
# Keep track of the current bookmarks in order to reset them later
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5387,12 +5387,12 @@ def summary(ui, repo, **opts):
cl = repo.changelog
for a in [cl.rev(n) for n in bheads]:
new[a] = 1
- for a in cl.ancestors(*[cl.rev(n) for n in bheads]):
+ for a in cl.ancestors([cl.rev(n) for n in bheads]):
new[a] = 1
for a in [p.rev() for p in parents]:
if a >= 0:
new[a] = 0
- for a in cl.ancestors(*[p.rev() for p in parents]):
+ for a in cl.ancestors([p.rev() for p in parents]):
new[a] = 0
new = sum(new)
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -223,7 +223,7 @@ class changectx(object):
return [changectx(self._repo, x) for x in c]
def ancestors(self):
- for a in self._repo.changelog.ancestors(self._rev):
+ for a in self._repo.changelog.ancestors([self._rev]):
yield changectx(self._repo, a)
def descendants(self):
@@ -1019,7 +1019,7 @@ class workingctx(changectx):
def ancestors(self):
for a in self._repo.changelog.ancestors(
- *[p.rev() for p in self._parents]):
+ [p.rev() for p in self._parents]):
yield changectx(self._repo, a)
def undelete(self, list):
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -140,7 +140,7 @@ def findcommonoutgoing(repo, other, only
og._computecommonmissing()
cl = repo.changelog
missingrevs = set(cl.rev(n) for n in og._missing)
- og._common = set(cl.ancestors(*missingrevs)) - missingrevs
+ og._common = set(cl.ancestors(missingrevs)) - missingrevs
commonheads = set(og.commonheads)
og.missingheads = [h for h in og.missingheads if h not in commonheads]
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1791,7 +1791,7 @@ class localrepository(repo.repository):
bases = [nullid]
csets, bases, heads = cl.nodesbetween(bases, heads)
# We assume that all ancestors of bases are known
- common = set(cl.ancestors(*[cl.rev(n) for n in bases]))
+ common = set(cl.ancestors([cl.rev(n) for n in bases]))
return self._changegroupsubset(common, csets, heads, source)
def getlocalbundle(self, source, outgoing):
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -381,7 +381,7 @@ class revlog(object):
visit.append(p)
return reachable
- def ancestors(self, *revs):
+ def ancestors(self, revs):
"""Generate the ancestors of 'revs' in reverse topological order.
Yield a sequence of revision numbers starting with the parents
@@ -441,7 +441,7 @@ class revlog(object):
heads = [self.rev(n) for n in heads]
# we want the ancestors, but inclusive
- has = set(self.ancestors(*common))
+ has = set(self.ancestors(common))
has.add(nullrev)
has.update(common)
diff --git a/tests/test-revlog-ancestry.py b/tests/test-revlog-ancestry.py
--- a/tests/test-revlog-ancestry.py
+++ b/tests/test-revlog-ancestry.py
@@ -47,15 +47,15 @@ if __name__ == '__main__':
# Ancestors
print 'Ancestors of 5'
- for r in repo.changelog.ancestors(5):
+ for r in repo.changelog.ancestors([5]):
print r,
print '\nAncestors of 6 and 5'
- for r in repo.changelog.ancestors(6, 5):
+ for r in repo.changelog.ancestors([6, 5]):
print r,
print '\nAncestors of 5 and 4'
- for r in repo.changelog.ancestors(5, 4):
+ for r in repo.changelog.ancestors([5, 4]):
print r,
# Descendants
More information about the Mercurial-devel
mailing list