803
797
yield rev_id, '.'.join(map(str, revno)), merge_depth
806
@deprecated_function(deprecated_in((2, 2, 0)))
807
def calculate_view_revisions(branch, start_revision, end_revision, direction,
808
specific_fileid, generate_merge_revisions):
809
"""Calculate the revisions to view.
811
:return: An iterator of (revision_id, dotted_revno, merge_depth) tuples OR
812
a list of the same tuples.
814
start_rev_id, end_rev_id = _get_revision_limits(branch, start_revision,
816
view_revisions = list(_calc_view_revisions(branch, start_rev_id, end_rev_id,
817
direction, generate_merge_revisions or specific_fileid))
819
view_revisions = _filter_revisions_touching_file_id(branch,
820
specific_fileid, view_revisions,
821
include_merges=generate_merge_revisions)
822
return _rebase_merge_depth(view_revisions)
825
800
def _rebase_merge_depth(view_revisions):
826
801
"""Adjust depths upwards so the top level is 0."""
827
802
# If either the first or last revision have a merge_depth of 0, we're done
888
863
if match is None:
889
864
return log_rev_iterator
890
searchRE = [(k, [re.compile(x, re.IGNORECASE) for x in v])
865
searchRE = [(k, [re.compile(x, re.IGNORECASE) for x in v])
891
866
for (k,v) in match.iteritems()]
892
867
return _filter_re(searchRE, log_rev_iterator)
905
880
'author': (rev.get_apparent_authors()),
906
881
'bugs': list(rev.iter_bugs())
908
strings[''] = [item for inner_list in strings.itervalues()
883
strings[''] = [item for inner_list in strings.itervalues()
909
884
for item in inner_list]
911
885
for (k,v) in searchRE:
912
886
if k in strings and not _match_any_filter(strings[k], v):
1184
1158
return mainline_revs, rev_nos, start_rev_id, end_rev_id
1187
@deprecated_function(deprecated_in((2, 2, 0)))
1188
def _filter_revision_range(view_revisions, start_rev_id, end_rev_id):
1189
"""Filter view_revisions based on revision ranges.
1191
:param view_revisions: A list of (revision_id, dotted_revno, merge_depth)
1192
tuples to be filtered.
1194
:param start_rev_id: If not NONE specifies the first revision to be logged.
1195
If NONE then all revisions up to the end_rev_id are logged.
1197
:param end_rev_id: If not NONE specifies the last revision to be logged.
1198
If NONE then all revisions up to the end of the log are logged.
1200
:return: The filtered view_revisions.
1202
if start_rev_id or end_rev_id:
1203
revision_ids = [r for r, n, d in view_revisions]
1205
start_index = revision_ids.index(start_rev_id)
1208
if start_rev_id == end_rev_id:
1209
end_index = start_index
1212
end_index = revision_ids.index(end_rev_id)
1214
end_index = len(view_revisions) - 1
1215
# To include the revisions merged into the last revision,
1216
# extend end_rev_id down to, but not including, the next rev
1217
# with the same or lesser merge_depth
1218
end_merge_depth = view_revisions[end_index][2]
1220
for index in xrange(end_index+1, len(view_revisions)+1):
1221
if view_revisions[index][2] <= end_merge_depth:
1222
end_index = index - 1
1225
# if the search falls off the end then log to the end as well
1226
end_index = len(view_revisions) - 1
1227
view_revisions = view_revisions[start_index:end_index+1]
1228
return view_revisions
1231
1161
def _filter_revisions_touching_file_id(branch, file_id, view_revisions,
1232
1162
include_merges=True):
1233
1163
r"""Return the list of revision ids which touch a given file id.
1315
@deprecated_function(deprecated_in((2, 2, 0)))
1316
def get_view_revisions(mainline_revs, rev_nos, branch, direction,
1317
include_merges=True):
1318
"""Produce an iterator of revisions to show
1319
:return: an iterator of (revision_id, revno, merge_depth)
1320
(if there is no revno for a revision, None is supplied)
1322
if not include_merges:
1323
revision_ids = mainline_revs[1:]
1324
if direction == 'reverse':
1325
revision_ids.reverse()
1326
for revision_id in revision_ids:
1327
yield revision_id, str(rev_nos[revision_id]), 0
1329
graph = branch.repository.get_graph()
1330
# This asks for all mainline revisions, which means we only have to spider
1331
# sideways, rather than depth history. That said, its still size-of-history
1332
# and should be addressed.
1333
# mainline_revisions always includes an extra revision at the beginning, so
1335
parent_map = dict(((key, value) for key, value in
1336
graph.iter_ancestry(mainline_revs[1:]) if value is not None))
1337
# filter out ghosts; merge_sort errors on ghosts.
1338
rev_graph = _mod_repository._strip_NULL_ghosts(parent_map)
1339
merge_sorted_revisions = tsort.merge_sort(
1343
generate_revno=True)
1345
if direction == 'forward':
1346
# forward means oldest first.
1347
merge_sorted_revisions = reverse_by_depth(merge_sorted_revisions)
1348
elif direction != 'reverse':
1349
raise ValueError('invalid direction %r' % direction)
1351
for (sequence, rev_id, merge_depth, revno, end_of_merge
1352
) in merge_sorted_revisions:
1353
yield rev_id, '.'.join(map(str, revno)), merge_depth
1356
1245
def reverse_by_depth(merge_sorted_revisions, _depth=0):
1357
1246
"""Reverse revisions by depth.
1956
1845
'The committer')
1959
def show_one_log(revno, rev, delta, verbose, to_file, show_timezone):
1960
# deprecated; for compatibility
1961
lf = LongLogFormatter(to_file=to_file, show_timezone=show_timezone)
1962
lf.show(revno, rev, delta)
1965
1848
def show_changed_revisions(branch, old_rh, new_rh, to_file=None,
1966
1849
log_format='long'):
1967
1850
"""Show the change in revision history comparing the old revision history to the new one.