Show More
@@ -85,28 +85,18 b' def pygments_format(filename, text, forc' | |||
|
85 | 85 | def filerevision_pygments(self, tmpl, fctx): |
|
86 | 86 | """Reimplement hgweb.filerevision to use syntax highlighting""" |
|
87 | 87 | f = fctx.path() |
|
88 | ||
|
89 | rawtext = fctx.data() | |
|
90 | text = rawtext | |
|
91 | ||
|
88 | text = fctx.data() | |
|
92 | 89 | fl = fctx.filelog() |
|
93 | 90 | n = fctx.filenode() |
|
94 | 91 | |
|
95 | mt = mimetypes.guess_type(f)[0] | |
|
96 | ||
|
97 | # we always want hgweb.encoding | |
|
98 | util._encoding = self.encoding | |
|
99 | ||
|
100 | 92 | if util.binary(text): |
|
101 | mt = mt or 'application/octet-stream' | |
|
93 | mt = mimetypes.guess_type(f)[0] or 'application/octet-stream' | |
|
102 | 94 | text = "(binary:%s)" % mt |
|
103 | ||
|
104 | 95 | # don't parse (binary:...) as anything |
|
105 | 96 | forcetext = True |
|
106 | 97 | else: |
|
107 | mt = mt or 'text/plain' | |
|
108 | ||
|
109 | 98 | # encode to hgweb.encoding for lexers and formatter |
|
99 | util._encoding = self.encoding | |
|
110 | 100 | text = util.tolocal(text) |
|
111 | 101 | forcetext = False |
|
112 | 102 | |
@@ -128,12 +118,10 b' def filerevision_pygments(self, tmpl, fc' | |||
|
128 | 118 | new_header = old_header + SYNTAX_CSS |
|
129 | 119 | tmpl.cache['header'] = new_header |
|
130 | 120 | |
|
131 |
|
|
|
121 | return tmpl("filerevision", | |
|
132 | 122 | file=f, |
|
133 | 123 | path=hgweb_mod._up(f), # fixme: make public |
|
134 | 124 | text=text_formatted, |
|
135 | raw=rawtext, | |
|
136 | mimetype=mt, | |
|
137 | 125 | rev=fctx.rev(), |
|
138 | 126 | node=hex(fctx.node()), |
|
139 | 127 | author=fctx.user(), |
General Comments 0
You need to be logged in to leave comments.
Login now