# HG changeset patch # User Yuya Nishihara # Date 1522766535 -32400 # Node ID 6a4de2dc78dd168677a2d27600d7075a72b619cc # Parent 3f70466ec7aa2f713b01dd3f90d34dadd62eb626 hgweb: wrap {lines} of {diff} with mappedgenerator This can't be a mappinggenerator as it switches the templates conditionally. diff -r 3f70466ec7aa -r 6a4de2dc78dd mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py Tue Apr 03 23:38:19 2018 +0900 +++ b/mercurial/hgweb/webutil.py Tue Apr 03 23:42:15 2018 +0900 @@ -519,7 +519,7 @@ return templateutil.mappedgenerator(_listfilediffsgen, args=(files, node, max)) -def _prettyprintdifflines(tmpl, lines, blockno, lineidprefix): +def _prettyprintdifflines(context, tmpl, lines, blockno, lineidprefix): for lineno, l in enumerate(lines, 1): difflineno = "%d.%d" % (blockno, lineno) if l.startswith('+'): @@ -562,11 +562,13 @@ continue lines.extend(hunklines) if lines: + l = templateutil.mappedgenerator(_prettyprintdifflines, + args=(web.tmpl, lines, blockno, + lineidprefix)) yield web.tmpl.generate('diffblock', { 'parity': next(parity), 'blockno': blockno, - 'lines': _prettyprintdifflines(web.tmpl, lines, blockno, - lineidprefix), + 'lines': l, }) def compare(tmpl, context, leftlines, rightlines):