/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-05 14:47:26 UTC
  • mfrom: (5752.2.11 2.4-windows-lfstat)
  • Revision ID: pqm@pqm.ubuntu.com-20110405144726-zi3lj2kwvjml4kx5
(jameinel) Add osutils.lstat/fstat so that even on Windows lstat(fname) ==
 fstat(open(fname).fileno()) (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
    repository as _mod_repository,
74
74
    revision as _mod_revision,
75
75
    revisionspec,
76
 
    trace,
77
76
    tsort,
78
77
    )
79
78
""")
84
83
from bzrlib.osutils import (
85
84
    format_date,
86
85
    format_date_with_offset_in_original_timezone,
 
86
    get_diff_header_encoding,
87
87
    get_terminal_encoding,
88
 
    re_compile_checked,
89
88
    terminal_width,
90
89
    )
91
90
from bzrlib.symbol_versioning import (
432
431
        else:
433
432
            specific_files = None
434
433
        s = StringIO()
 
434
        path_encoding = get_diff_header_encoding()
435
435
        diff.show_diff_trees(tree_1, tree_2, s, specific_files, old_label='',
436
 
            new_label='')
 
436
            new_label='', path_encoding=path_encoding)
437
437
        return s.getvalue()
438
438
 
439
439
    def _create_log_revision_iterator(self):
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:
802
809
    """
803
810
    if search is None:
804
811
        return log_rev_iterator
805
 
    searchRE = re_compile_checked(search, re.IGNORECASE,
806
 
            'log message filter')
 
812
    searchRE = re.compile(search, re.IGNORECASE)
807
813
    return _filter_message_re(searchRE, log_rev_iterator)
808
814
 
809
815
 
2010
2016
      kind is one of values 'directory', 'file', 'symlink', 'tree-reference'.
2011
2017
      branch will be read-locked.
2012
2018
    """
2013
 
    from builtins import _get_revision_range, safe_relpath_files
 
2019
    from builtins import _get_revision_range
2014
2020
    tree, b, path = bzrdir.BzrDir.open_containing_tree_or_branch(file_list[0])
2015
2021
    add_cleanup(b.lock_read().unlock)
2016
2022
    # XXX: It's damn messy converting a list of paths to relative paths when
2022
2028
    # case of running log in a nested directory, assuming paths beyond the
2023
2029
    # first one haven't been deleted ...
2024
2030
    if tree:
2025
 
        relpaths = [path] + safe_relpath_files(tree, file_list[1:])
 
2031
        relpaths = [path] + tree.safe_relpath_files(file_list[1:])
2026
2032
    else:
2027
2033
        relpaths = [path] + file_list[1:]
2028
2034
    info_list = []