/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/log.py

  • Committer: Martin Pool
  • Date: 2009-01-13 05:16:26 UTC
  • mfrom: (3936 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3940.
  • Revision ID: mbp@sourcefrog.net-20090113051626-0d5q6luqdoyx4xaf
Fix recommend_upgrade ui and merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1010
1010
                 search=None)
1011
1011
 
1012
1012
 
 
1013
def get_history_change(old_revision_id, new_revision_id, repository):
 
1014
    """Calculate the uncommon lefthand history between two revisions.
 
1015
 
 
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.
 
1019
 
 
1020
    return old_history, new_history
 
1021
    """
 
1022
    old_history = []
 
1023
    old_revisions = set()
 
1024
    new_history = []
 
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
 
1029
    do_old = True
 
1030
    do_new = True
 
1031
    while do_new or do_old:
 
1032
        if do_new:
 
1033
            try:
 
1034
                new_revision = new_iter.next()
 
1035
            except StopIteration:
 
1036
                do_new = False
 
1037
            else:
 
1038
                new_history.append(new_revision)
 
1039
                new_revisions.add(new_revision)
 
1040
                if new_revision in old_revisions:
 
1041
                    stop_revision = new_revision
 
1042
                    break
 
1043
        if do_old:
 
1044
            try:
 
1045
                old_revision = old_iter.next()
 
1046
            except StopIteration:
 
1047
                do_old = False
 
1048
            else:
 
1049
                old_history.append(old_revision)
 
1050
                old_revisions.add(old_revision)
 
1051
                if old_revision in new_revisions:
 
1052
                    stop_revision = old_revision
 
1053
                    break
 
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
 
1060
 
 
1061
 
 
1062
def show_branch_change(branch, output, old_revno, old_revision_id):
 
1063
    """Show the changes made to a branch.
 
1064
 
 
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.
 
1069
    """
 
1070
    new_revno, new_revision_id = branch.last_revision_info()
 
1071
    old_history, new_history = get_history_change(old_revision_id,
 
1072
                                                  new_revision_id,
 
1073
                                                  branch.repository)
 
1074
    if old_history == [] and new_history == []:
 
1075
        output.write('Nothing seems to have changed\n')
 
1076
        return
 
1077
 
 
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,)
 
1091
 
 
1092
 
 
1093
def show_flat_log(repository, history, last_revno, lf):
 
1094
    """Show a simple log of the specified history.
 
1095
 
 
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.
 
1100
    """
 
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)
 
1105
        lf.log_revision(lr)
 
1106
 
 
1107
 
1013
1108
properties_handler_registry = registry.Registry()
1014
1109
properties_handler_registry.register_lazy("foreign",
1015
1110
                                          "bzrlib.foreign",