changeset 38091:6369e21e97ac

hgweb: use template context to render {diffstat} This is a preferred way to process nested templates.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 04 Apr 2018 00:20:47 +0900
parents f0ee627162f4
children 4c3ab15f3532
files mercurial/hgweb/webutil.py
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webutil.py	Wed Apr 04 00:19:37 2018 +0900
+++ b/mercurial/hgweb/webutil.py	Wed Apr 04 00:20:47 2018 +0900
@@ -670,7 +670,7 @@
     return _(' %d files changed, %d insertions(+), %d deletions(-)\n') % (
              len(stats), addtotal, removetotal)
 
-def _diffstattmplgen(context, tmpl, ctx, statgen, parity):
+def _diffstattmplgen(context, ctx, statgen, parity):
     stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen)
     files = ctx.files()
 
@@ -684,7 +684,7 @@
         template = 'diffstatlink' if filename in files else 'diffstatnolink'
         total = adds + removes
         fileno += 1
-        yield tmpl.generate(template, {
+        yield context.process(template, {
             'node': ctx.hex(),
             'file': filename,
             'fileno': fileno,
@@ -696,7 +696,7 @@
 
 def diffstat(tmpl, ctx, statgen, parity):
     '''Return a diffstat template for each file in the diff.'''
-    args = (tmpl, ctx, statgen, parity)
+    args = (ctx, statgen, parity)
     return templateutil.mappedgenerator(_diffstattmplgen, args=args)
 
 class sessionvars(templateutil.wrapped):