##// END OF EJS Templates
ancestors: ensure a consistent order even in the "inclusive" case...
Boris Feld -
r39510:a60dae06 default
parent child Browse files
Show More
@@ -309,31 +309,30 b' class lazyancestors(object):'
309 revision number order. That order is also topological: a child is
309 revision number order. That order is also topological: a child is
310 always emitted before its parent.
310 always emitted before its parent.
311
311
312 If inclusive is True, yield all the revs first (ignoring stoprev),
312 If inclusive is True, the source revisions are also yielded. The
313 then yield all the ancestors of revs as when inclusive is False. If an
313 reverse revision number order is still enforced."""
314 element in revs is an ancestor of a different rev it is not yielded
315 again."""
316 seen = set()
314 seen = set()
317 revs = self._initrevs
315 revs = self._initrevs
318 if self._inclusive:
319 for rev in revs:
320 yield rev
321 seen.update(revs)
322
316
323 parentrevs = self._parentrevs
317 parentrevs = self._parentrevs
324 stoprev = self._stoprev
318 stoprev = self._stoprev
325 visit = []
326 heapq.heapify(visit)
327 schedule = heapq.heappush
319 schedule = heapq.heappush
328 nextitem = heapq.heappop
320 nextitem = heapq.heappop
329 see = seen.add
321 see = seen.add
330 see(nullrev)
322 see(nullrev)
331
323
332 for r in revs:
324 if self._inclusive:
333 for parent in parentrevs(r):
325 visit = [-r for r in revs]
334 if parent not in seen:
326 seen.update(revs)
335 schedule(visit, -parent)
327 heapq.heapify(visit)
336 see(parent)
328 else:
329 visit = []
330 heapq.heapify(visit)
331 for r in revs:
332 for parent in parentrevs(r):
333 if parent not in seen:
334 schedule(visit, -parent)
335 see(parent)
337
336
338 while visit:
337 while visit:
339 current = -nextitem(visit)
338 current = -nextitem(visit)
@@ -9,10 +9,10 b' membership: [1, 0]'
9 iteration: [1, 0]
9 iteration: [1, 0]
10 % lazy ancestor set for [11, 13], stoprev = 0, inclusive = True
10 % lazy ancestor set for [11, 13], stoprev = 0, inclusive = True
11 membership: [11, 13, 7, 8, 3, 4, 1, 0]
11 membership: [11, 13, 7, 8, 3, 4, 1, 0]
12 iteration: [11, 13, 8, 7, 4, 3, 2, 1, 0]
12 iteration: [13, 11, 8, 7, 4, 3, 2, 1, 0]
13 % lazy ancestor set for [11, 13], stoprev = 6, inclusive = False
13 % lazy ancestor set for [11, 13], stoprev = 6, inclusive = False
14 membership: [7, 8]
14 membership: [7, 8]
15 iteration: [8, 7]
15 iteration: [8, 7]
16 % lazy ancestor set for [11, 13], stoprev = 6, inclusive = True
16 % lazy ancestor set for [11, 13], stoprev = 6, inclusive = True
17 membership: [11, 13, 7, 8]
17 membership: [11, 13, 7, 8]
18 iteration: [11, 13, 8, 7]
18 iteration: [13, 11, 8, 7]
@@ -9,7 +9,7 b' 6'
9 Ancestors of 7, including revs
9 Ancestors of 7, including revs
10 7 6 5 4 3 2 1 0
10 7 6 5 4 3 2 1 0
11 Ancestors of 7, 5 and 3, including revs
11 Ancestors of 7, 5 and 3, including revs
12 7 5 3 6 4 2 1 0
12 7 6 5 4 3 2 1 0
13
13
14 Descendants of 5
14 Descendants of 5
15 7 8
15 7 8
General Comments 0
You need to be logged in to leave comments. Login now