Patchwork [2,of,7] hgweb: use template context to render {diffstat}

login
register
mail settings
Submitter Yuya Nishihara
Date May 13, 2018, 3:19 a.m.
Message ID <672d62e1224e0bd7350a.1526181599@mimosa>
Download mbox | patch
Permalink /patch/31570/
State Accepted
Headers show

Comments

Yuya Nishihara - May 13, 2018, 3:19 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522768847 -32400
#      Wed Apr 04 00:20:47 2018 +0900
# Node ID 672d62e1224e0bd7350a917d45e6a38e82adfc29
# Parent  19ec816173c015626e2001e14ed3fe2be7a13d8b
hgweb: use template context to render {diffstat}

This is a preferred way to process nested templates.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -654,7 +654,7 @@  def diffsummary(statgen):
     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()
 
@@ -668,7 +668,7 @@  def _diffstattmplgen(context, tmpl, ctx,
         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,
@@ -680,7 +680,7 @@  def _diffstattmplgen(context, tmpl, ctx,
 
 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):