Show More
@@ -20,43 +20,43 b' from . import (' | |||||
20 | baseset = smartset.baseset |
|
20 | baseset = smartset.baseset | |
21 | generatorset = smartset.generatorset |
|
21 | generatorset = smartset.generatorset | |
22 |
|
22 | |||
23 | def revancestors(repo, revs, followfirst): |
|
23 | def _genrevancestors(repo, revs, followfirst): | |
24 | """Like revlog.ancestors(), but supports followfirst.""" |
|
|||
25 | if followfirst: |
|
24 | if followfirst: | |
26 | cut = 1 |
|
25 | cut = 1 | |
27 | else: |
|
26 | else: | |
28 | cut = None |
|
27 | cut = None | |
29 | cl = repo.changelog |
|
28 | cl = repo.changelog | |
|
29 | revs.sort(reverse=True) | |||
|
30 | irevs = iter(revs) | |||
|
31 | h = [] | |||
30 |
|
32 | |||
31 | def iterate(): |
|
33 | inputrev = next(irevs, None) | |
32 | revs.sort(reverse=True) |
|
34 | if inputrev is not None: | |
33 | irevs = iter(revs) |
|
35 | heapq.heappush(h, -inputrev) | |
34 | h = [] |
|
|||
35 |
|
||||
36 | inputrev = next(irevs, None) |
|
|||
37 | if inputrev is not None: |
|
|||
38 | heapq.heappush(h, -inputrev) |
|
|||
39 |
|
36 | |||
40 |
|
|
37 | seen = set() | |
41 |
|
|
38 | while h: | |
42 |
|
|
39 | current = -heapq.heappop(h) | |
43 |
|
|
40 | if current == inputrev: | |
44 |
|
|
41 | inputrev = next(irevs, None) | |
45 |
|
|
42 | if inputrev is not None: | |
46 |
|
|
43 | heapq.heappush(h, -inputrev) | |
47 |
|
|
44 | if current not in seen: | |
48 |
|
|
45 | seen.add(current) | |
49 |
|
|
46 | yield current | |
50 |
|
|
47 | try: | |
51 |
|
|
48 | for parent in cl.parentrevs(current)[:cut]: | |
52 |
|
|
49 | if parent != node.nullrev: | |
53 |
|
|
50 | heapq.heappush(h, -parent) | |
54 |
|
|
51 | except error.WdirUnsupported: | |
55 |
|
|
52 | for parent in repo[current].parents()[:cut]: | |
56 |
|
|
53 | if parent.rev() != node.nullrev: | |
57 |
|
|
54 | heapq.heappush(h, -parent.rev()) | |
58 |
|
55 | |||
59 | return generatorset(iterate(), iterasc=False) |
|
56 | def revancestors(repo, revs, followfirst): | |
|
57 | """Like revlog.ancestors(), but supports followfirst.""" | |||
|
58 | gen = _genrevancestors(repo, revs, followfirst) | |||
|
59 | return generatorset(gen, iterasc=False) | |||
60 |
|
60 | |||
61 | def revdescendants(repo, revs, followfirst): |
|
61 | def revdescendants(repo, revs, followfirst): | |
62 | """Like revlog.descendants() but supports followfirst.""" |
|
62 | """Like revlog.descendants() but supports followfirst.""" |
General Comments 0
You need to be logged in to leave comments.
Login now