changeset 38028:6a4de2dc78dd

hgweb: wrap {lines} of {diff} with mappedgenerator This can't be a mappinggenerator as it switches the templates conditionally.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 03 Apr 2018 23:42:15 +0900
parents 3f70466ec7aa
children 7a9e9fbaa559
files mercurial/hgweb/webutil.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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):