/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 breezy/annotate.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-07-25 00:54:22 UTC
  • mfrom: (7045.1.23 python3-p)
  • Revision ID: breezy.the.bot@gmail.com-20180725005422-a1rubn7zssfn2uvu
Fix some more tests on Python 3.

Merged from https://code.launchpad.net/~jelmer/brz/python3-p/+merge/349784

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
    if to_file is None:
75
75
        to_file = sys.stdout
76
76
 
 
77
    encoding = osutils.get_terminal_encoding()
77
78
    # Handle the show_ids case
78
79
    annotations = list(tree.annotate_iter(path, file_id))
79
80
    if show_ids:
80
 
        return _show_id_annotations(annotations, to_file, full)
 
81
        return _show_id_annotations(annotations, to_file, full, encoding)
81
82
 
82
83
    if not getattr(tree, "get_revision_id", False):
83
84
        # Create a virtual revision to represent the current tree state.
96
97
        current_rev = None
97
98
    annotation = list(_expand_annotations(annotations, branch,
98
99
        current_rev))
99
 
    _print_annotations(annotation, verbose, to_file, full)
100
 
 
101
 
 
102
 
def _print_annotations(annotation, verbose, to_file, full):
 
100
    _print_annotations(annotation, verbose, to_file, full, encoding)
 
101
 
 
102
 
 
103
def _print_annotations(annotation, verbose, to_file, full, encoding):
103
104
    """Print annotations to to_file.
104
105
 
105
106
    :param to_file: The file to output the annotation to.
132
133
        # GZ 2017-05-21: Writing both unicode annotation and bytes from file
133
134
        # which the given to_file must cope with.
134
135
        to_file.write(anno)
135
 
        to_file.write('| %s\n' % (text,))
 
136
        to_file.write('| %s\n' % (text.decode(encoding),))
136
137
        prevanno = anno
137
138
 
138
139
 
139
 
def _show_id_annotations(annotations, to_file, full):
 
140
def _show_id_annotations(annotations, to_file, full, encoding):
140
141
    if not annotations:
141
142
        return
142
143
    last_rev_id = None
145
146
        if full or last_rev_id != origin:
146
147
            this = origin
147
148
        else:
148
 
            this = ''
149
 
        to_file.write('%*s | %s' % (max_origin_len, this, text))
 
149
            this = b''
 
150
        to_file.write('%*s | %s' % (max_origin_len, this.decode('utf-8'),
 
151
            text.decode(encoding)))
150
152
        last_rev_id = origin
151
153
    return
152
154