Show More
@@ -381,8 +381,9 b' class revlog(object):' | |||||
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, stoprev=0): | |
385 | """Generate the ancestors of 'revs' in reverse topological order. |
|
385 | """Generate the ancestors of 'revs' in reverse topological order. | |
|
386 | Does not generate revs lower than stoprev. | |||
386 |
|
387 | |||
387 | Yield a sequence of revision numbers starting with the parents |
|
388 | Yield a sequence of revision numbers starting with the parents | |
388 | of each revision in revs, i.e., each revision is *not* considered |
|
389 | of each revision in revs, i.e., each revision is *not* considered | |
@@ -393,6 +394,8 b' class revlog(object):' | |||||
393 | seen = set([nullrev]) |
|
394 | seen = set([nullrev]) | |
394 | while visit: |
|
395 | while visit: | |
395 | for parent in self.parentrevs(visit.popleft()): |
|
396 | for parent in self.parentrevs(visit.popleft()): | |
|
397 | if parent < stoprev: | |||
|
398 | continue | |||
396 | if parent not in seen: |
|
399 | if parent not in seen: | |
397 | visit.append(parent) |
|
400 | visit.append(parent) | |
398 | seen.add(parent) |
|
401 | seen.add(parent) |
@@ -58,6 +58,10 b" if __name__ == '__main__':" | |||||
58 | for r in repo.changelog.ancestors([5, 4]): |
|
58 | for r in repo.changelog.ancestors([5, 4]): | |
59 | print r, |
|
59 | print r, | |
60 |
|
60 | |||
|
61 | print '\nAncestors of 7, stop at 6' | |||
|
62 | for r in repo.changelog.ancestors([7], 6): | |||
|
63 | print r, | |||
|
64 | ||||
61 | # Descendants |
|
65 | # Descendants | |
62 | print '\n\nDescendants of 5' |
|
66 | print '\n\nDescendants of 5' | |
63 | for r in repo.changelog.descendants([5]): |
|
67 | for r in repo.changelog.descendants([5]): |
General Comments 0
You need to be logged in to leave comments.
Login now