Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 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 | cafd8a8fb713 |
children | 1093ad1e8903 |
comparison
equal
deleted
inserted
replaced
16865:a6543fdcf869 | 16866:91f3ac205816 |
---|---|
379 if p not in reachable: | 379 if p not in reachable: |
380 reachable.add(p) | 380 reachable.add(p) |
381 visit.append(p) | 381 visit.append(p) |
382 return reachable | 382 return reachable |
383 | 383 |
384 def ancestors(self, *revs): | 384 def ancestors(self, revs): |
385 """Generate the ancestors of 'revs' in reverse topological order. | 385 """Generate the ancestors of 'revs' in reverse topological order. |
386 | 386 |
387 Yield a sequence of revision numbers starting with the parents | 387 Yield a sequence of revision numbers starting with the parents |
388 of each revision in revs, i.e., each revision is *not* considered | 388 of each revision in revs, i.e., each revision is *not* considered |
389 an ancestor of itself. Results are in breadth-first order: | 389 an ancestor of itself. Results are in breadth-first order: |
439 | 439 |
440 common = [self.rev(n) for n in common] | 440 common = [self.rev(n) for n in common] |
441 heads = [self.rev(n) for n in heads] | 441 heads = [self.rev(n) for n in heads] |
442 | 442 |
443 # we want the ancestors, but inclusive | 443 # we want the ancestors, but inclusive |
444 has = set(self.ancestors(*common)) | 444 has = set(self.ancestors(common)) |
445 has.add(nullrev) | 445 has.add(nullrev) |
446 has.update(common) | 446 has.update(common) |
447 | 447 |
448 # take all ancestors from heads that aren't in has | 448 # take all ancestors from heads that aren't in has |
449 missing = set() | 449 missing = set() |