449
449
last_key = (last_revision,)
450
450
known_graph = self.repository.revisions.get_known_graph_ancestry(
452
revs = known_graph.merge_sort(last_key)
453
self._merge_sorted_revisions_cache = [(key[-1], d, rn, eom)
454
for key, d, rn, eom in revs]
452
self._merge_sorted_revisions_cache = known_graph.merge_sort(
456
454
filtered = self._filter_merge_sorted_revisions(
457
455
self._merge_sorted_revisions_cache, start_revision_id,
458
456
stop_revision_id, stop_rule)
468
466
"""Iterate over an inclusive range of sorted revisions."""
469
467
rev_iter = iter(merge_sorted_revisions)
470
468
if start_revision_id is not None:
471
for rev_id, depth, revno, end_of_merge in rev_iter:
469
for node in rev_iter:
470
rev_id = node.key[-1]
472
471
if rev_id != start_revision_id:
475
474
# The decision to include the start or not
476
475
# depends on the stop_rule if a stop is provided
478
iter([(rev_id, depth, revno, end_of_merge)]),
476
# so pop this node back into the iterator
477
rev_iter = chain(iter([node]), rev_iter)
481
479
if stop_revision_id is None:
482
for rev_id, depth, revno, end_of_merge in rev_iter:
483
yield rev_id, depth, revno, end_of_merge
481
for node in rev_iter:
482
rev_id = node.key[-1]
483
yield (rev_id, node.merge_depth, node.revno,
484
485
elif stop_rule == 'exclude':
485
for rev_id, depth, revno, end_of_merge in rev_iter:
486
for node in rev_iter:
487
rev_id = node.key[-1]
486
488
if rev_id == stop_revision_id:
488
yield rev_id, depth, revno, end_of_merge
490
yield (rev_id, node.merge_depth, node.revno,
489
492
elif stop_rule == 'include':
490
for rev_id, depth, revno, end_of_merge in rev_iter:
491
yield rev_id, depth, revno, end_of_merge
493
for node in rev_iter:
494
rev_id = node.key[-1]
495
yield (rev_id, node.merge_depth, node.revno,
492
497
if rev_id == stop_revision_id:
494
499
elif stop_rule == 'with-merges':
497
502
left_parent = stop_rev.parent_ids[0]
499
504
left_parent = _mod_revision.NULL_REVISION
500
for rev_id, depth, revno, end_of_merge in rev_iter:
505
for node in rev_iter:
506
rev_id = node.key[-1]
501
507
if rev_id == left_parent:
503
yield rev_id, depth, revno, end_of_merge
509
yield (rev_id, node.merge_depth, node.revno,
505
512
raise ValueError('invalid stop_rule %r' % stop_rule)