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

login
register
mail settings
Submitter Yuya Nishihara
Date May 10, 2018, 2:16 p.m.
Message ID <9c179b856572b90bb7f6.1525961770@mimosa>
Download mbox | patch
Permalink /patch/31462/
State Accepted
Headers show

Comments

Yuya Nishihara - May 10, 2018, 2:16 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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=''):