[PATCH 5 of 6] hgweb: use template context to render {files} of changelist entries

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


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1522766034 -32400
#      Tue Apr 03 23:33:54 2018 +0900
# Node ID 9c179b856572b90bb7f6db3131ba1b1f607c2f68
# Parent  6d4ea75a83203052e9524ccbfadfd53fbfc4d25b
hgweb: use template context to render {files} of changelist entries

This is a preferred way to process nested templates.

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -509,15 +509,15 @@ def changesetentry(web, ctx):
         archives=web.archivelist(ctx.hex()),
         **pycompat.strkwargs(commonentry(web.repo, ctx)))
 
-def _listfilediffsgen(context, tmpl, files, node, max):
+def _listfilediffsgen(context, files, node, max):
     for f in files[:max]:
-        yield tmpl.generate('filedifflink', {'node': hex(node), 'file': f})
+        yield context.process('filedifflink', {'node': hex(node), 'file': f})
     if len(files) > max:
-        yield tmpl.generate('fileellipses', {})
+        yield context.process('fileellipses', {})
 
 def listfilediffs(tmpl, files, node, max):
     return templateutil.mappedgenerator(_listfilediffsgen,
-                                        args=(tmpl, files, node, max))
+                                        args=(files, node, max))
 
 def diffs(web, ctx, basectx, files, style, linerange=None,
           lineidprefix=''):


More information about the Mercurial-devel mailing list