/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: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import sys
31
31
import time
32
32
 
33
 
from breezy.lazy_import import lazy_import
 
33
from .lazy_import import lazy_import
34
34
lazy_import(globals(), """
35
35
from breezy import (
36
36
    patiencediff,
37
37
    tsort,
38
38
    )
39
39
""")
40
 
from breezy import (
 
40
from . import (
41
41
    errors,
42
42
    osutils,
43
43
    )
44
 
from breezy.config import extract_email_address
45
 
from breezy.repository import _strip_NULL_ghosts
46
 
from breezy.revision import (
 
44
from .config import extract_email_address
 
45
from .repository import _strip_NULL_ghosts
 
46
from .revision import (
47
47
    CURRENT_REVISION,
48
48
    Revision,
49
49
    )
114
114
 
115
115
    # Output the annotations
116
116
    prevanno = ''
117
 
    encoding = getattr(to_file, 'encoding', None) or \
118
 
            osutils.get_terminal_encoding()
119
117
    for (revno_str, author, date_str, line_rev_id, text) in annotation:
120
118
        if verbose:
121
119
            anno = '%-*s %-*s %8s ' % (max_revno_len, revno_str,
126
124
            anno = "%-*s %-7s " % (max_revno_len, revno_str, author[:7])
127
125
        if anno.lstrip() == "" and full:
128
126
            anno = prevanno
129
 
        try:
130
 
            to_file.write(anno)
131
 
        except UnicodeEncodeError:
132
 
            # cmd_annotate should be passing in an 'exact' object, which means
133
 
            # we have a direct handle to sys.stdout or equivalent. It may not
134
 
            # be able to handle the exact Unicode characters, but 'annotate' is
135
 
            # a user function (non-scripting), so shouldn't die because of
136
 
            # unrepresentable annotation characters. So encode using 'replace',
137
 
            # and write them again.
138
 
            to_file.write(anno.encode(encoding, 'replace'))
 
127
        # GZ 2017-05-21: Writing both unicode annotation and bytes from file
 
128
        # which the given to_file must cope with.
 
129
        to_file.write(anno)
139
130
        to_file.write('| %s\n' % (text,))
140
131
        prevanno = anno
141
132
 
440
431
 
441
432
try:
442
433
    from breezy._annotator_pyx import Annotator
443
 
except ImportError, e:
 
434
except ImportError as e:
444
435
    osutils.failed_to_load_extension(e)
445
436
    from breezy._annotator_py import Annotator