~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2010-02-09 19:04:02 UTC
  • mfrom: (5010 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5019.
  • Revision ID: mbp@canonical.com-20100209190402-2xbzrchmb4dfi2j7
Resolve conflicts with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
    re_compile_checked,
89
89
    terminal_width,
90
90
    )
 
91
from bzrlib.symbol_versioning import (
 
92
    deprecated_function,
 
93
    deprecated_in,
 
94
    )
91
95
 
92
96
 
93
97
def find_touching_revisions(branch, file_id):
304
308
 
305
309
 
306
310
class Logger(object):
307
 
    """An object the generates, formats and displays a log."""
 
311
    """An object that generates, formats and displays a log."""
308
312
 
309
313
    def __init__(self, branch, rqst):
310
314
        """Create a Logger.
530
534
 
531
535
 
532
536
def _generate_all_revisions(branch, start_rev_id, end_rev_id, direction,
533
 
    delayed_graph_generation):
 
537
                            delayed_graph_generation):
534
538
    # On large trees, generating the merge graph can take 30-60 seconds
535
539
    # so we delay doing it until a merge is detected, incrementally
536
540
    # returning initial (non-merge) revisions while we can.
 
541
 
 
542
    # The above is only true for old formats (<= 0.92), for newer formats, a
 
543
    # couple of seconds only should be needed to load the whole graph and the
 
544
    # other graph operations needed are even faster than that -- vila 100201
537
545
    initial_revisions = []
538
546
    if delayed_graph_generation:
539
547
        try:
540
 
            for rev_id, revno, depth in \
541
 
                _linear_view_revisions(branch, start_rev_id, end_rev_id):
 
548
            for rev_id, revno, depth in  _linear_view_revisions(
 
549
                branch, start_rev_id, end_rev_id):
542
550
                if _has_merges(branch, rev_id):
 
551
                    # The end_rev_id can be nested down somewhere. We need an
 
552
                    # explicit ancestry check. There is an ambiguity here as we
 
553
                    # may not raise _StartNotLinearAncestor for a revision that
 
554
                    # is an ancestor but not a *linear* one. But since we have
 
555
                    # loaded the graph to do the check (or calculate a dotted
 
556
                    # revno), we may as well accept to show the log... 
 
557
                    # -- vila 100201
 
558
                    graph = branch.repository.get_graph()
 
559
                    if not graph.is_ancestor(start_rev_id, end_rev_id):
 
560
                        raise _StartNotLinearAncestor()
543
561
                    end_rev_id = rev_id
544
562
                    break
545
563
                else:
597
615
        else:
598
616
            # not obvious
599
617
            return False
 
618
    # if either start or end is not specified then we use either the first or
 
619
    # the last revision and *they* are obvious ancestors.
600
620
    return True
601
621
 
602
622
 
664
684
                depth_adjustment = merge_depth
665
685
            if depth_adjustment:
666
686
                if merge_depth < depth_adjustment:
 
687
                    # From now on we reduce the depth adjustement, this can be
 
688
                    # surprising for users. The alternative requires two passes
 
689
                    # which breaks the fast display of the first revision
 
690
                    # though.
667
691
                    depth_adjustment = merge_depth
668
692
                merge_depth -= depth_adjustment
669
693
            yield rev_id, '.'.join(map(str, revno)), merge_depth
670
694
 
671
695
 
 
696
@deprecated_function(deprecated_in((2, 2, 0)))
672
697
def calculate_view_revisions(branch, start_revision, end_revision, direction,
673
698
        specific_fileid, generate_merge_revisions):
674
699
    """Calculate the revisions to view.
676
701
    :return: An iterator of (revision_id, dotted_revno, merge_depth) tuples OR
677
702
             a list of the same tuples.
678
703
    """
679
 
    # This method is no longer called by the main code path.
680
 
    # It is retained for API compatibility and may be deprecated
681
 
    # soon. IGC 20090116
682
704
    start_rev_id, end_rev_id = _get_revision_limits(branch, start_revision,
683
705
        end_revision)
684
706
    view_revisions = list(_calc_view_revisions(branch, start_rev_id, end_rev_id,
1034
1056
    return mainline_revs, rev_nos, start_rev_id, end_rev_id
1035
1057
 
1036
1058
 
 
1059
@deprecated_function(deprecated_in((2, 2, 0)))
1037
1060
def _filter_revision_range(view_revisions, start_rev_id, end_rev_id):
1038
1061
    """Filter view_revisions based on revision ranges.
1039
1062
 
1048
1071
 
1049
1072
    :return: The filtered view_revisions.
1050
1073
    """
1051
 
    # This method is no longer called by the main code path.
1052
 
    # It may be removed soon. IGC 20090127
1053
1074
    if start_rev_id or end_rev_id:
1054
1075
        revision_ids = [r for r, n, d in view_revisions]
1055
1076
        if start_rev_id:
1161
1182
    return result
1162
1183
 
1163
1184
 
 
1185
@deprecated_function(deprecated_in((2, 2, 0)))
1164
1186
def get_view_revisions(mainline_revs, rev_nos, branch, direction,
1165
1187
                       include_merges=True):
1166
1188
    """Produce an iterator of revisions to show
1167
1189
    :return: an iterator of (revision_id, revno, merge_depth)
1168
1190
    (if there is no revno for a revision, None is supplied)
1169
1191
    """
1170
 
    # This method is no longer called by the main code path.
1171
 
    # It is retained for API compatibility and may be deprecated
1172
 
    # soon. IGC 20090127
1173
1192
    if not include_merges:
1174
1193
        revision_ids = mainline_revs[1:]
1175
1194
        if direction == 'reverse':
1293
1312
    preferred_levels = 0
1294
1313
 
1295
1314
    def __init__(self, to_file, show_ids=False, show_timezone='original',
1296
 
            delta_format=None, levels=None, show_advice=False,
1297
 
            to_exact_file=None):
 
1315
                 delta_format=None, levels=None, show_advice=False,
 
1316
                 to_exact_file=None):
1298
1317
        """Create a LogFormatter.
1299
1318
 
1300
1319
        :param to_file: the file to output to