# HG changeset patch # User Yuya Nishihara # Date 2018-04-03 15:19:37 # Node ID f0ee627162f46b03635e6cf0a97f0179b83a1c1e # Parent 9aaa74f9eb87c56787aed4fac036784c43e85dbc 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(). diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -670,9 +670,7 @@ def diffsummary(statgen): 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 @@ def diffstat(tmpl, ctx, statgen, parity) '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