~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-04-07 18:38:07 UTC
  • Revision ID: mnordhoff@mattnordhoff.com-20090407183807-s4ih1lkwobo8w46z
Make LoggerheadConfig a new-style class

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)
95
85
                    change=change, text=hl_lines[lineno - 1])
96
86
                lineno += 1
97
87
 
98
 
        self.log.debug('annotate: %r secs' % (time.time() - z,))
 
88
        self.log.debug('annotate: %r secs' % (time.time() - z))
99
89
 
100
90
    def get_values(self, path, kwargs, headers):
101
91
        history = self._history