changeset 38090:f0ee627162f4

hgweb: wrap {diffstat} with mappedgenerator This can't be a mappinggenerator since the associated templates are switched per item. We already have webutil.diffstatgen(). That's why the generator function is named as _diffstattmplgen().
author Yuya Nishihara <yuya@tcha.org>
date Wed, 04 Apr 2018 00:19:37 +0900
parents 9aaa74f9eb87
children 6369e21e97ac
files mercurial/hgweb/webutil.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webutil.py	Fri May 18 20:43:01 2018 -0400
+++ b/mercurial/hgweb/webutil.py	Wed Apr 04 00:19:37 2018 +0900
@@ -670,9 +670,7 @@
     return _(' %d files changed, %d insertions(+), %d deletions(-)\n') % (
              len(stats), addtotal, removetotal)
 
-def diffstat(tmpl, ctx, statgen, parity):
-    '''Return a diffstat template for each file in the diff.'''
-
+def _diffstattmplgen(context, tmpl, ctx, statgen, parity):
     stats, maxname, maxtotal, addtotal, removetotal, binary = next(statgen)
     files = ctx.files()
 
@@ -696,6 +694,11 @@
             'parity': next(parity),
         })
 
+def diffstat(tmpl, ctx, statgen, parity):
+    '''Return a diffstat template for each file in the diff.'''
+    args = (tmpl, ctx, statgen, parity)
+    return templateutil.mappedgenerator(_diffstattmplgen, args=args)
+
 class sessionvars(templateutil.wrapped):
     def __init__(self, vars, start='?'):
         self._start = start