1013
def get_history_change(old_revision_id, new_revision_id, repository):
1014
"""Calculate the uncommon lefthand history between two revisions.
1016
:param old_revision_id: The original revision id.
1017
:param new_revision_id: The new revision id.
1018
:param repository: The repository to use for the calculation.
1020
return old_history, new_history
1023
old_revisions = set()
1025
new_revisions = set()
1026
new_iter = repository.iter_reverse_revision_history(new_revision_id)
1027
old_iter = repository.iter_reverse_revision_history(old_revision_id)
1028
stop_revision = None
1031
while do_new or do_old:
1034
new_revision = new_iter.next()
1035
except StopIteration:
1038
new_history.append(new_revision)
1039
new_revisions.add(new_revision)
1040
if new_revision in old_revisions:
1041
stop_revision = new_revision
1045
old_revision = old_iter.next()
1046
except StopIteration:
1049
old_history.append(old_revision)
1050
old_revisions.add(old_revision)
1051
if old_revision in new_revisions:
1052
stop_revision = old_revision
1054
new_history.reverse()
1055
old_history.reverse()
1056
if stop_revision is not None:
1057
new_history = new_history[new_history.index(stop_revision) + 1:]
1058
old_history = old_history[old_history.index(stop_revision) + 1:]
1059
return old_history, new_history
1062
def show_branch_change(branch, output, old_revno, old_revision_id):
1063
"""Show the changes made to a branch.
1065
:param branch: The branch to show changes about.
1066
:param output: A file-like object to write changes to.
1067
:param old_revno: The revno of the old tip.
1068
:param old_revision_id: The revision_id of the old tip.
1070
new_revno, new_revision_id = branch.last_revision_info()
1071
old_history, new_history = get_history_change(old_revision_id,
1074
if old_history == [] and new_history == []:
1075
output.write('Nothing seems to have changed\n')
1078
log_format = log_formatter_registry.get_default(branch)
1079
lf = log_format(show_ids=False, to_file=output, show_timezone='original')
1080
if old_history != []:
1081
output.write('*'*60)
1082
output.write('\nRemoved Revisions:\n')
1083
show_flat_log(branch.repository, old_history, old_revno, lf)
1084
output.write('*'*60)
1085
output.write('\n\n')
1086
if new_history != []:
1087
output.write('Added Revisions:\n')
1088
start_revno = new_revno - len(new_history) + 1
1089
show_log(branch, lf, None, verbose=False, direction='forward',
1090
start_revision=start_revno,)
1093
def show_flat_log(repository, history, last_revno, lf):
1094
"""Show a simple log of the specified history.
1096
:param repository: The repository to retrieve revisions from.
1097
:param history: A list of revision_ids indicating the lefthand history.
1098
:param last_revno: The revno of the last revision_id in the history.
1099
:param lf: The log formatter to use.
1101
start_revno = last_revno - len(history) + 1
1102
revisions = repository.get_revisions(history)
1103
for i, rev in enumerate(revisions):
1104
lr = LogRevision(rev, i + last_revno, 0, None)
1013
1108
properties_handler_registry = registry.Registry()
1014
1109
properties_handler_registry.register_lazy("foreign",
1015
1110
"bzrlib.foreign",