~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2010-08-13 07:56:06 UTC
  • mfrom: (5050.17.4 2.2)
  • mto: (5050.17.6 2.2)
  • mto: This revision was merged to the branch mainline in revision 5379.
  • Revision ID: mbp@sourcefrog.net-20100813075606-8zgmov3ezwans2zo
merge bzr 2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
    diff,
71
71
    errors,
72
72
    foreign,
 
73
    osutils,
73
74
    repository as _mod_repository,
74
75
    revision as _mod_revision,
75
76
    revisionspec,
85
86
    format_date,
86
87
    format_date_with_offset_in_original_timezone,
87
88
    get_terminal_encoding,
88
 
    re_compile_checked,
89
89
    terminal_width,
90
90
    )
91
91
from bzrlib.symbol_versioning import (
432
432
        else:
433
433
            specific_files = None
434
434
        s = StringIO()
 
435
        path_encoding = osutils.get_diff_header_encoding()
435
436
        diff.show_diff_trees(tree_1, tree_2, s, specific_files, old_label='',
436
 
            new_label='')
 
437
            new_label='', path_encoding=path_encoding)
437
438
        return s.getvalue()
438
439
 
439
440
    def _create_log_revision_iterator(self):
522
523
    elif not generate_merge_revisions:
523
524
        # If we only want to see linear revisions, we can iterate ...
524
525
        iter_revs = _generate_flat_revisions(branch, start_rev_id, end_rev_id,
525
 
                                             direction)
 
526
                                             direction, exclude_common_ancestry)
526
527
        if direction == 'forward':
527
528
            iter_revs = reversed(iter_revs)
528
529
    else:
544
545
        return [(rev_id, revno_str, 0)]
545
546
 
546
547
 
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)
 
548
def _generate_flat_revisions(branch, start_rev_id, end_rev_id, direction,
 
549
                             exclude_common_ancestry=False):
 
550
    result = _linear_view_revisions(
 
551
        branch, start_rev_id, end_rev_id,
 
552
        exclude_common_ancestry=exclude_common_ancestry)
549
553
    # If a start limit was given and it's not obviously an
550
554
    # ancestor of the end limit, check it before outputting anything
551
555
    if direction == 'forward' or (start_rev_id
572
576
    if delayed_graph_generation:
573
577
        try:
574
578
            for rev_id, revno, depth in  _linear_view_revisions(
575
 
                branch, start_rev_id, end_rev_id):
 
579
                branch, start_rev_id, end_rev_id, exclude_common_ancestry):
576
580
                if _has_merges(branch, rev_id):
577
581
                    # The end_rev_id can be nested down somewhere. We need an
578
582
                    # explicit ancestry check. There is an ambiguity here as we
643
647
    return True
644
648
 
645
649
 
646
 
def _linear_view_revisions(branch, start_rev_id, end_rev_id):
 
650
def _linear_view_revisions(branch, start_rev_id, end_rev_id,
 
651
                           exclude_common_ancestry=False):
647
652
    """Calculate a sequence of revisions to view, newest to oldest.
648
653
 
649
654
    :param start_rev_id: the lower revision-id
650
655
    :param end_rev_id: the upper revision-id
 
656
    :param exclude_common_ancestry: Whether the start_rev_id should be part of
 
657
        the iterated revisions.
651
658
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples.
652
659
    :raises _StartNotLinearAncestor: if a start_rev_id is specified but
653
 
      is not found walking the left-hand history
 
660
        is not found walking the left-hand history
654
661
    """
655
662
    br_revno, br_rev_id = branch.last_revision_info()
656
663
    repo = branch.repository
667
674
            revno = branch.revision_id_to_dotted_revno(revision_id)
668
675
            revno_str = '.'.join(str(n) for n in revno)
669
676
            if not found_start and revision_id == start_rev_id:
670
 
                yield revision_id, revno_str, 0
 
677
                if not exclude_common_ancestry:
 
678
                    yield revision_id, revno_str, 0
671
679
                found_start = True
672
680
                break
673
681
            else:
802
810
    """
803
811
    if search is None:
804
812
        return log_rev_iterator
805
 
    searchRE = re_compile_checked(search, re.IGNORECASE,
806
 
            'log message filter')
 
813
    searchRE = re.compile(search, re.IGNORECASE)
807
814
    return _filter_message_re(searchRE, log_rev_iterator)
808
815
 
809
816