[PATCH] highlight: update according to latest hgweb_mod changes
Christian Ebert
blacktrash at gmx.net
Thu Jan 31 06:58:51 CST 2008
# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1201784268 -3600
# Node ID 9e288c15b3f6c518e4f30b3708811f8105b826be
# Parent 6dcc190ffc36c0fc1b410b32f547324b10d2e27c
highlight: update according to latest hgweb_mod changes
Also move encoding workaround completely into non binary condition.
diff --git a/hgext/highlight.py b/hgext/highlight.py
--- a/hgext/highlight.py
+++ b/hgext/highlight.py
@@ -85,28 +85,18 @@
def filerevision_pygments(self, tmpl, fctx):
"""Reimplement hgweb.filerevision to use syntax highlighting"""
f = fctx.path()
-
- rawtext = fctx.data()
- text = rawtext
-
+ text = fctx.data()
fl = fctx.filelog()
n = fctx.filenode()
- mt = mimetypes.guess_type(f)[0]
-
- # we always want hgweb.encoding
- util._encoding = self.encoding
-
if util.binary(text):
- mt = mt or 'application/octet-stream'
+ mt = mimetypes.guess_type(f)[0] or 'application/octet-stream'
text = "(binary:%s)" % mt
-
# don't parse (binary:...) as anything
forcetext = True
else:
- mt = mt or 'text/plain'
-
# encode to hgweb.encoding for lexers and formatter
+ util._encoding = self.encoding
text = util.tolocal(text)
forcetext = False
@@ -128,12 +118,10 @@
new_header = old_header + SYNTAX_CSS
tmpl.cache['header'] = new_header
- yield tmpl("filerevision",
+ return tmpl("filerevision",
file=f,
path=hgweb_mod._up(f), # fixme: make public
text=text_formatted,
- raw=rawtext,
- mimetype=mt,
rev=fctx.rev(),
node=hex(fctx.node()),
author=fctx.user(),
More information about the Mercurial-devel
mailing list