~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

Clean up the lock.py code to use less indenting, and conform to better coding practise.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
from bzrlib import (
32
32
    errors,
33
 
    osutils,
34
33
    patiencediff,
35
34
    tsort,
36
35
    )
80
79
            anno = "%-*s %-7s " % (max_revno_len, revno_str, author[:7])
81
80
 
82
81
        if anno.lstrip() == "" and full: anno = prevanno
83
 
        try:
84
 
            to_file.write(anno)
85
 
        except UnicodeEncodeError:
86
 
            # cmd_annotate should be passing in an 'exact' object, which means
87
 
            # we have a direct handle to sys.stdout or equivalent. It may not
88
 
            # be able to handle the exact Unicode characters, but 'annotate' is
89
 
            # a user function (non-scripting), so shouldn't die because of
90
 
            # unrepresentable annotation characters. So encode using 'replace',
91
 
            # and write them again.
92
 
            encoding = getattr(to_file, 'encoding', None) or \
93
 
                    osutils.get_terminal_encoding()
94
 
            to_file.write(anno.encode(encoding, 'replace'))
95
 
        print >>to_file, '| %s' % (text,)
 
82
        print >>to_file, '%s| %s' % (anno, text)
96
83
        prevanno=anno
97
84
 
98
85
 
102
89
    This includes detailed information, such as the committer name, and
103
90
    date string for the commit, rather than just the revision id.
104
91
    """
105
 
    revision_id_to_revno = branch.get_revision_id_to_revno_map()
 
92
    branch_last_revision = branch.last_revision()
 
93
    revision_graph = branch.repository.get_revision_graph(branch_last_revision)
 
94
    merge_sorted_revisions = tsort.merge_sort(
 
95
        revision_graph,
 
96
        branch_last_revision,
 
97
        None,
 
98
        generate_revno=True)
 
99
    revision_id_to_revno = dict((rev_id, revno)
 
100
                                for seq_num, rev_id, depth, revno, end_of_merge
 
101
                                 in merge_sorted_revisions)
106
102
    w = branch.repository.weave_store.get_weave(file_id,
107
103
        branch.repository.get_transaction())
108
104
    last_origin = None