hgweb: wrap {lines} of {diff} with mappedgenerator
This can't be a mappinggenerator as it switches the templates conditionally.
--- 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):