455
455
generate_merge_revisions = rqst.get('levels') != 1
456
456
delayed_graph_generation = not rqst.get('specific_fileids') and (
457
457
rqst.get('limit') or self.start_rev_id or self.end_rev_id)
458
view_revisions = _calc_view_revisions(self.branch, self.start_rev_id,
459
self.end_rev_id, rqst.get('direction'), generate_merge_revisions,
458
view_revisions = _calc_view_revisions(
459
self.branch, self.start_rev_id, self.end_rev_id,
460
rqst.get('direction'),
461
generate_merge_revisions=generate_merge_revisions,
460
462
delayed_graph_generation=delayed_graph_generation)
462
464
# Apply the other filters
470
472
# Note that we always generate the merge revisions because
471
473
# filter_revisions_touching_file_id() requires them ...
473
view_revisions = _calc_view_revisions(self.branch, self.start_rev_id,
474
self.end_rev_id, rqst.get('direction'), True)
475
view_revisions = _calc_view_revisions(
476
self.branch, self.start_rev_id, self.end_rev_id,
477
rqst.get('direction'), generate_merge_revisions=True)
475
478
if not isinstance(view_revisions, list):
476
479
view_revisions = list(view_revisions)
477
480
view_revisions = _filter_revisions_touching_file_id(self.branch,
488
491
:return: An iterator of (revision_id, dotted_revno, merge_depth) tuples OR
489
492
a list of the same tuples.
494
if direction not in ('reverse', 'forward'):
495
raise ValueError('invalid direction %r' % direction)
491
496
br_revno, br_rev_id = branch.last_revision_info()
492
497
if br_revno == 0:
495
# If a single revision is requested, check we can handle it
496
generate_single_revision = (end_rev_id and start_rev_id == end_rev_id and
497
(not generate_merge_revisions or not _has_merges(branch, end_rev_id)))
498
if generate_single_revision:
499
return _generate_one_revision(branch, end_rev_id, br_rev_id, br_revno)
501
# If we only want to see linear revisions, we can iterate ...
502
if not generate_merge_revisions:
503
return _generate_flat_revisions(branch, start_rev_id, end_rev_id,
500
if (end_rev_id and start_rev_id == end_rev_id
501
and (not generate_merge_revisions
502
or not _has_merges(branch, end_rev_id))):
503
# If a single revision is requested, check we can handle it
504
iter_revs = _generate_one_revision(branch, end_rev_id, br_rev_id,
506
elif not generate_merge_revisions:
507
# If we only want to see linear revisions, we can iterate ...
508
iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
510
if direction == 'forward':
511
iter_revs = reversed(iter_revs)
506
return _generate_all_revisions(branch, start_rev_id, end_rev_id,
507
direction, delayed_graph_generation)
513
iter_revs = _generate_all_revisions(branch, start_rev_id, end_rev_id,
514
direction, delayed_graph_generation)
515
if direction == 'forward':
516
iter_revs = _rebase_merge_depth(reverse_by_depth(list(iter_revs)))
510
520
def _generate_one_revision(branch, rev_id, br_rev_id, br_revno):
569
577
initial_revisions.append((rev_id, revno, depth))
571
579
# No merged revisions found
572
if direction == 'reverse':
573
return initial_revisions
574
elif direction == 'forward':
575
return reversed(initial_revisions)
577
raise ValueError('invalid direction %r' % direction)
580
return initial_revisions
578
581
except _StartNotLinearAncestor:
579
582
# A merge was never detected so the lower revision limit can't
580
583
# be nested down somewhere
592
595
view_revisions = chain(iter(initial_revisions),
593
596
_graph_view_revisions(branch, start_rev_id, end_rev_id,
594
597
rebase_initial_depths=(direction == 'reverse')))
595
if direction == 'reverse':
596
return view_revisions
597
elif direction == 'forward':
598
# Forward means oldest first, adjusting for depth.
599
view_revisions = reverse_by_depth(list(view_revisions))
600
return _rebase_merge_depth(view_revisions)
602
raise ValueError('invalid direction %r' % direction)
598
return view_revisions
605
601
def _has_merges(branch, rev_id):