hgweb: wrap {files} of changelist entries with mappedgenerator
authorYuya Nishihara <yuya@tcha.org>
Tue, 03 Apr 2018 23:32:16 +0900
changeset 37996 028d7c24f2e5
parent 37995 c4313a9fde7b
child 37997 4237d07fad2c
hgweb: wrap {files} of changelist entries with mappedgenerator This also switches the associated templates conditionally, which can't be a mappinggenerator.
mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py	Tue Apr 03 23:31:11 2018 +0900
+++ b/mercurial/hgweb/webutil.py	Tue Apr 03 23:32:16 2018 +0900
@@ -509,12 +509,16 @@
         archives=web.archivelist(ctx.hex()),
         **pycompat.strkwargs(commonentry(web.repo, ctx)))
 
-def listfilediffs(tmpl, files, node, max):
+def _listfilediffsgen(context, tmpl, files, node, max):
     for f in files[:max]:
         yield tmpl.generate('filedifflink', {'node': hex(node), 'file': f})
     if len(files) > max:
         yield tmpl.generate('fileellipses', {})
 
+def listfilediffs(tmpl, files, node, max):
+    return templateutil.mappedgenerator(_listfilediffsgen,
+                                        args=(tmpl, files, node, max))
+
 def diffs(web, ctx, basectx, files, style, linerange=None,
           lineidprefix=''):