# HG changeset patch # User Yuya Nishihara # Date 2018-04-03 14:42:15 # 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 --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py --- a/mercurial/hgweb/webutil.py +++ b/mercurial/hgweb/webutil.py @@ -519,7 +519,7 @@ def listfilediffs(files, node, max): 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 @@ def diffs(web, ctx, basectx, files, styl 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):