diff hgext/highlight/__init__.py @ 36884:ece242db5000

hgweb: use templater on requestcontext instance After this commit, all @webcommand function no longer use their "tmpl" argument. Instead, they use the templater attached to the requestcontext. This is the same exact object. So there should be no difference in behavior. Differential Revision: https://phab.mercurial-scm.org/D2800
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 20:38:28 -0800
parents 67fb0dca29bc
children 563fd95a6efb
line wrap: on
line diff
--- a/hgext/highlight/__init__.py	Sat Mar 10 19:41:18 2018 -0800
+++ b/hgext/highlight/__init__.py	Sat Mar 10 20:38:28 2018 -0800
@@ -58,8 +58,8 @@
         highlight.pygmentize(field, fctx, style, tmpl,
                 guessfilenameonly=filenameonly)
 
-def filerevision_highlight(orig, web, req, tmpl, fctx):
-    mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
+def filerevision_highlight(orig, web, req, fctx):
+    mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding))
     # only pygmentize for mimetype containing 'html' so we both match
     # 'text/html' and possibly 'application/xhtml+xml' in the future
     # so that we don't have to touch the extension when the mimetype
@@ -68,17 +68,17 @@
     # can't clash with the file's content-type here in case we
     # pygmentize a html file
     if 'html' in mt:
-        pygmentize(web, 'fileline', fctx, tmpl)
+        pygmentize(web, 'fileline', fctx, web.tmpl)
 
-    return orig(web, req, tmpl, fctx)
+    return orig(web, req, fctx)
 
 def annotate_highlight(orig, web, req, tmpl):
-    mt = ''.join(tmpl('mimetype', encoding=encoding.encoding))
+    mt = ''.join(web.tmpl('mimetype', encoding=encoding.encoding))
     if 'html' in mt:
         fctx = webutil.filectx(web.repo, req)
-        pygmentize(web, 'annotateline', fctx, tmpl)
+        pygmentize(web, 'annotateline', fctx, web.tmpl)
 
-    return orig(web, req, tmpl)
+    return orig(web, req, web.tmpl)
 
 def generate_css(web, req, tmpl):
     pg_style = web.config('web', 'pygments_style', 'colorful')