[PATCH 4 of 6] hgweb: wrap {files} of changelist entries with mappedgenerator

Yuya Nishihara yuya at tcha.org
Thu May 10 10:16:09 EDT 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1522765936 -32400
#      Tue Apr 03 23:32:16 2018 +0900
# Node ID 6d4ea75a83203052e9524ccbfadfd53fbfc4d25b
# Parent  ed028b800abd0c73d12b3fe6b26a3f43668c6ceb
hgweb: wrap {files} of changelist entries with mappedgenerator

This also switches the associated templates conditionally, which can't be
a mappinggenerator.

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -509,12 +509,16 @@ def changesetentry(web, ctx):
         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=''):
 


More information about the Mercurial-devel mailing list