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."""
309
313
def __init__(self, branch, rqst):
310
314
"""Create a Logger.
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.
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:
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...
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
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
667
691
depth_adjustment = merge_depth
668
692
merge_depth -= depth_adjustment
669
693
yield rev_id, '.'.join(map(str, revno)), merge_depth
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.
679
# This method is no longer called by the main code path.
680
# It is retained for API compatibility and may be deprecated
682
704
start_rev_id, end_rev_id = _get_revision_limits(branch, start_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
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.
1049
1072
:return: The filtered view_revisions.
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:
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)
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
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.
1300
1319
:param to_file: the file to output to