~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/controllers/annotate_ui.py

  • Committer: Matt Nordhoff
  • Date: 2009-05-13 14:03:48 UTC
  • mto: (389.2.2 pep8-2009-10)
  • mto: This revision was merged to the branch mainline in revision 392.
  • Revision ID: mnordhoff@mattnordhoff.com-20090513140348-yn43gztulksm62e9
Always use a tuple in string formatting

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
import bzrlib.errors
25
25
import bzrlib.textfile
26
 
import bzrlib.osutils
27
26
 
28
27
from paste.httpexceptions import HTTPBadRequest, HTTPServerError
29
28
 
49
48
 
50
49
        file_name = os.path.basename(self._history.get_path(revid, file_id))
51
50
 
52
 
        file_text = tree.get_file_text(file_id)
53
 
        encoding = 'utf-8'
54
 
        try:
55
 
            file_text = file_text.decode(encoding)
56
 
        except UnicodeDecodeError:
57
 
            encoding = 'iso-8859-15'
58
 
            file_text = file_text.decode(encoding)
59
 
 
60
 
        file_lines = bzrlib.osutils.split_lines(file_text)
61
 
 
62
 
        try:
 
51
        try:
 
52
            file_lines = tree.get_file_lines(file_id)
63
53
            bzrlib.textfile.check_text_lines(file_lines)
64
54
        except bzrlib.errors.BinaryFile:
65
 
            # bail out; this isn't displayable text
66
 
            yield util.Container(parity=0, lineno=1, status='same',
67
 
                                 text='(This is a binary file.)',
68
 
                                 change=util.Container())
 
55
                # bail out; this isn't displayable text
 
56
                yield util.Container(parity=0, lineno=1, status='same',
 
57
                                     text='(This is a binary file.)',
 
58
                                     change=util.Container())
69
59
        else:
70
60
            if highlight is not None:
71
 
                hl_lines = highlight(file_name, file_text, encoding)
 
61
                hl_lines = highlight(file_name, ''.join(file_lines))
72
62
                hl_lines.extend([u''] * (len(file_lines) - len(hl_lines)))
73
63
            else:
74
64
                hl_lines = map(cgi.escape, file_lines)