~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Vincent Ladeuil
  • Date: 2010-06-08 09:50:27 UTC
  • mto: (5284.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5285.
  • Revision ID: v.ladeuil+lp@free.fr-20100608095027-nxvyibss2uefgcg1
Respect --exclude-common-ancestry for linear ancestries.

* bzrlib/tests/test_log.py:
(TestLogExcludeAncestry.test_merge_sorted_simple_revnos_exclude_ancestry):
There are two different code paths that exhibit bug #575631.

* bzrlib/log.py:
(_calc_view_revisions, _generate_flat_revisions): Propagate
exclude_common_ancestry into more code paths.
(_linear_view_revisions): Don't yield start_rev_id when we want to
exclude the common ancestry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
522
522
    elif not generate_merge_revisions:
523
523
        # If we only want to see linear revisions, we can iterate ...
524
524
        iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
525
 
                                             direction)
 
525
                                             direction, exclude_common_ancestry)
526
526
        if direction == 'forward':
527
527
            iter_revs = reversed(iter_revs)
528
528
    else:
544
544
        return [(rev_id, revno_str, 0)]
545
545
 
546
546
 
547
 
def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction):
548
 
    result = _linear_view_revisions(branch, start_rev_id, end_rev_id)
 
547
def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction,
 
548
                             exclude_common_ancestry=False):
 
549
    result = _linear_view_revisions(
 
550
        branch, start_rev_id, end_rev_id,
 
551
        exclude_common_ancestry=exclude_common_ancestry)
549
552
    # If a start limit was given and it's not obviously an
550
553
    # ancestor of the end limit, check it before outputting anything
551
554
    if direction == 'forward' or (start_rev_id
572
575
    if delayed_graph_generation:
573
576
        try:
574
577
            for rev_id, revno, depth in  _linear_view_revisions(
575
 
                branch, start_rev_id, end_rev_id):
 
578
                branch, start_rev_id, end_rev_id, exclude_common_ancestry):
576
579
                if _has_merges(branch, rev_id):
577
580
                    # The end_rev_id can be nested down somewhere. We need an
578
581
                    # explicit ancestry check. There is an ambiguity here as we
643
646
    return True
644
647
 
645
648
 
646
 
def _linear_view_revisions(branch, start_rev_id, end_rev_id):
 
649
def _linear_view_revisions(branch, start_rev_id, end_rev_id,
 
650
                           exclude_common_ancestry=False):
647
651
    """Calculate a sequence of revisions to view, newest to oldest.
648
652
 
649
653
    :param start_rev_id: the lower revision-id
650
654
    :param end_rev_id: the upper revision-id
 
655
    :param exclude_common_ancestry: Whether the start_rev_id should be part of
 
656
        the iterated revisions.
651
657
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples.
652
658
    :raises _StartNotLinearAncestor: if a start_rev_id is specified but
653
 
      is not found walking the left-hand history
 
659
        is not found walking the left-hand history
654
660
    """
655
661
    br_revno, br_rev_id = branch.last_revision_info()
656
662
    repo = branch.repository
667
673
            revno = branch.revision_id_to_dotted_revno(revision_id)
668
674
            revno_str = '.'.join(str(n) for n in revno)
669
675
            if not found_start and revision_id == start_rev_id:
670
 
                yield revision_id, revno_str, 0
 
676
                if not exclude_common_ancestry:
 
677
                    yield revision_id, revno_str, 0
671
678
                found_start = True
672
679
                break
673
680
            else: