Mercurial > hg
changeset 16866:91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
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.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Fri, 01 Jun 2012 12:37:18 -0700 |
parents | a6543fdcf869 |
children | 1093ad1e8903 |
files | contrib/perf.py hgext/rebase.py mercurial/commands.py mercurial/context.py mercurial/discovery.py mercurial/localrepo.py mercurial/revlog.py tests/test-revlog-ancestry.py |
diffstat | 8 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/perf.py Tue May 29 23:26:55 2012 +0200 +++ b/contrib/perf.py Fri Jun 01 12:37:18 2012 -0700 @@ -74,7 +74,7 @@ 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)
--- a/hgext/rebase.py Tue May 29 23:26:55 2012 +0200 +++ b/hgext/rebase.py Fri Jun 01 12:37:18 2012 -0700 @@ -224,7 +224,7 @@ 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 @@ # 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
--- a/mercurial/commands.py Tue May 29 23:26:55 2012 +0200 +++ b/mercurial/commands.py Fri Jun 01 12:37:18 2012 -0700 @@ -5396,12 +5396,12 @@ 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)
--- a/mercurial/context.py Tue May 29 23:26:55 2012 +0200 +++ b/mercurial/context.py Fri Jun 01 12:37:18 2012 -0700 @@ -223,7 +223,7 @@ 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 @@ 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):
--- a/mercurial/discovery.py Tue May 29 23:26:55 2012 +0200 +++ b/mercurial/discovery.py Fri Jun 01 12:37:18 2012 -0700 @@ -140,7 +140,7 @@ 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]
--- a/mercurial/localrepo.py Tue May 29 23:26:55 2012 +0200 +++ b/mercurial/localrepo.py Fri Jun 01 12:37:18 2012 -0700 @@ -1791,7 +1791,7 @@ 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):
--- a/mercurial/revlog.py Tue May 29 23:26:55 2012 +0200 +++ b/mercurial/revlog.py Fri Jun 01 12:37:18 2012 -0700 @@ -381,7 +381,7 @@ 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 @@ 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)
--- a/tests/test-revlog-ancestry.py Tue May 29 23:26:55 2012 +0200 +++ b/tests/test-revlog-ancestry.py Fri Jun 01 12:37:18 2012 -0700 @@ -47,15 +47,15 @@ # 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