Show More
@@ -283,14 +283,22 b' def _lazyancestorsiter(parentrevs, initr' | |||||
283 | see(p2) |
|
283 | see(p2) | |
284 |
|
284 | |||
285 | while visit: |
|
285 | while visit: | |
286 |
current = - |
|
286 | current = -visit[0] | |
287 | if current < stoprev: |
|
287 | if current < stoprev: | |
288 | break |
|
288 | break | |
289 | yield current |
|
289 | yield current | |
|
290 | # optimize out heapq operation if p1 is known to be the next highest | |||
|
291 | # revision, which is quite common in linear history. | |||
290 | p1, p2 = parentrevs(current) |
|
292 | p1, p2 = parentrevs(current) | |
291 | if p1 not in seen: |
|
293 | if p1 not in seen: | |
|
294 | if current - p1 == 1: | |||
|
295 | visit[0] = -p1 | |||
|
296 | else: | |||
|
297 | nextitem(visit) | |||
292 | schedule(visit, -p1) |
|
298 | schedule(visit, -p1) | |
293 | see(p1) |
|
299 | see(p1) | |
|
300 | else: | |||
|
301 | nextitem(visit) | |||
294 | if p2 not in seen: |
|
302 | if p2 not in seen: | |
295 | schedule(visit, -p2) |
|
303 | schedule(visit, -p2) | |
296 | see(p2) |
|
304 | see(p2) |
@@ -221,6 +221,10 b' def test_lazyancestors():' | |||||
221 | s = genlazyancestors([11, 13], stoprev=12, inclusive=True) |
|
221 | s = genlazyancestors([11, 13], stoprev=12, inclusive=True) | |
222 | printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0]) |
|
222 | printlazyancestors(s, [11, 13, 7, 9, 8, 3, 6, 4, 1, -1, 0]) | |
223 |
|
223 | |||
|
224 | # Contiguous chains: 5->4, 2->1 (where 1 is in seen set), 1->0 | |||
|
225 | s = genlazyancestors([10, 1], inclusive=True) | |||
|
226 | printlazyancestors(s, [2, 10, 4, 5, -1, 0, 1]) | |||
|
227 | ||||
224 | # The C gca algorithm requires a real repo. These are textual descriptions of |
|
228 | # The C gca algorithm requires a real repo. These are textual descriptions of | |
225 | # DAGs that have been known to be problematic, and, optionally, known pairs |
|
229 | # DAGs that have been known to be problematic, and, optionally, known pairs | |
226 | # of revisions and their expected ancestor list. |
|
230 | # of revisions and their expected ancestor list. |
@@ -22,3 +22,6 b' iteration: [13, 11]' | |||||
22 | % lazy ancestor set for [11, 13], stoprev = 12, inclusive = True |
|
22 | % lazy ancestor set for [11, 13], stoprev = 12, inclusive = True | |
23 | membership: [13] |
|
23 | membership: [13] | |
24 | iteration: [13] |
|
24 | iteration: [13] | |
|
25 | % lazy ancestor set for [10, 1], stoprev = 0, inclusive = True | |||
|
26 | membership: [2, 10, 4, 5, 0, 1] | |||
|
27 | iteration: [10, 5, 4, 2, 1, 0] |
General Comments 0
You need to be logged in to leave comments.
Login now