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().
--- 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