251
251
raise errors.BzrCommandError('Selected log formatter only supports'
252
252
' mainline revisions.')
253
253
generate_merge_revisions = generate_single_revision
254
include_merges = generate_merge_revisions or specific_fileid
254
255
view_revs_iter = get_view_revisions(mainline_revs, rev_nos, branch,
255
direction, include_merges=generate_merge_revisions)
256
direction, include_merges=include_merges)
257
258
if direction == 'reverse':
258
259
start_rev_id, end_rev_id = end_rev_id, start_rev_id
833
839
if len(revision.rev.parent_ids) > 1:
834
840
is_merge = ' [merge]'
835
to_file.write("%5s %s\t%s%s\n" % (revision.revno,
843
tags = ' {%s}' % (', '.join(revision.tags))
845
to_file.write("%5s %s\t%s%s%s\n" % (revision.revno,
836
846
self.short_author(revision.rev),
837
847
format_date(revision.rev.timestamp,
838
848
revision.rev.timezone or 0,
839
849
self.show_timezone, date_fmt="%Y-%m-%d",
840
850
show_offset=False),
842
852
if self.show_ids:
843
853
to_file.write(' revision-id:%s\n'
844
854
% (revision.rev.revision_id,))
882
893
def log_revision(self, revision):
883
894
self.to_file.write(self.log_string(revision.revno, revision.rev,
895
self._max_chars, revision.tags))
885
896
self.to_file.write('\n')
887
def log_string(self, revno, rev, max_chars):
898
def log_string(self, revno, rev, max_chars, tags=None):
888
899
"""Format log info into one string. Truncate tail of string
889
900
:param revno: revision number or None.
890
901
Revision numbers counts from 1.
891
:param rev: revision info object
902
:param rev: revision object
892
903
:param max_chars: maximum length of resulting string
904
:param tags: list of tags or None
893
905
:return: formatted truncated string
1028
def get_history_change(old_revision_id, new_revision_id, repository):
1029
"""Calculate the uncommon lefthand history between two revisions.
1031
:param old_revision_id: The original revision id.
1032
:param new_revision_id: The new revision id.
1033
:param repository: The repository to use for the calculation.
1035
return old_history, new_history
1038
old_revisions = set()
1040
new_revisions = set()
1041
new_iter = repository.iter_reverse_revision_history(new_revision_id)
1042
old_iter = repository.iter_reverse_revision_history(old_revision_id)
1043
stop_revision = None
1046
while do_new or do_old:
1049
new_revision = new_iter.next()
1050
except StopIteration:
1053
new_history.append(new_revision)
1054
new_revisions.add(new_revision)
1055
if new_revision in old_revisions:
1056
stop_revision = new_revision
1060
old_revision = old_iter.next()
1061
except StopIteration:
1064
old_history.append(old_revision)
1065
old_revisions.add(old_revision)
1066
if old_revision in new_revisions:
1067
stop_revision = old_revision
1069
new_history.reverse()
1070
old_history.reverse()
1071
if stop_revision is not None:
1072
new_history = new_history[new_history.index(stop_revision) + 1:]
1073
old_history = old_history[old_history.index(stop_revision) + 1:]
1074
return old_history, new_history
1077
def show_branch_change(branch, output, old_revno, old_revision_id):
1078
"""Show the changes made to a branch.
1080
:param branch: The branch to show changes about.
1081
:param output: A file-like object to write changes to.
1082
:param old_revno: The revno of the old tip.
1083
:param old_revision_id: The revision_id of the old tip.
1085
new_revno, new_revision_id = branch.last_revision_info()
1086
old_history, new_history = get_history_change(old_revision_id,
1089
if old_history == [] and new_history == []:
1090
output.write('Nothing seems to have changed\n')
1093
log_format = log_formatter_registry.get_default(branch)
1094
lf = log_format(show_ids=False, to_file=output, show_timezone='original')
1095
if old_history != []:
1096
output.write('*'*60)
1097
output.write('\nRemoved Revisions:\n')
1098
show_flat_log(branch.repository, old_history, old_revno, lf)
1099
output.write('*'*60)
1100
output.write('\n\n')
1101
if new_history != []:
1102
output.write('Added Revisions:\n')
1103
start_revno = new_revno - len(new_history) + 1
1104
show_log(branch, lf, None, verbose=False, direction='forward',
1105
start_revision=start_revno,)
1108
def show_flat_log(repository, history, last_revno, lf):
1109
"""Show a simple log of the specified history.
1111
:param repository: The repository to retrieve revisions from.
1112
:param history: A list of revision_ids indicating the lefthand history.
1113
:param last_revno: The revno of the last revision_id in the history.
1114
:param lf: The log formatter to use.
1116
start_revno = last_revno - len(history) + 1
1117
revisions = repository.get_revisions(history)
1118
for i, rev in enumerate(revisions):
1119
lr = LogRevision(rev, i + last_revno, 0, None)
1013
1123
properties_handler_registry = registry.Registry()
1014
1124
properties_handler_registry.register_lazy("foreign",
1015
1125
"bzrlib.foreign",