Patchwork [3,of,6] hgweb: use template context to render {files} of changesetentry()

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

Comments

Yuya Nishihara - May 10, 2018, 2:16 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522765871 -32400
#      Tue Apr 03 23:31:11 2018 +0900
# Node ID ed028b800abd0c73d12b3fe6b26a3f43668c6ceb
# Parent  9dfcd4fe82f9e71aad3275df35a17232a889af07
hgweb: use template context to render {files} of changesetentry()

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
@@ -463,11 +463,11 @@  def symrevorshortnode(req, ctx):
     else:
         return short(ctx.node())
 
-def _listfilesgen(context, tmpl, ctx, stripecount):
+def _listfilesgen(context, ctx, stripecount):
     parity = paritygen(stripecount)
     for blockno, f in enumerate(ctx.files()):
         template = 'filenodelink' if f in ctx else 'filenolink'
-        yield tmpl.generate(template, {
+        yield context.process(template, {
             'node': ctx.hex(),
             'file': f,
             'blockno': blockno + 1,
@@ -503,8 +503,7 @@  def changesetentry(web, ctx):
         changesetbookmark=showbookmarks,
         changesetbranch=showbranch,
         files=templateutil.mappedgenerator(_listfilesgen,
-                                           args=(web.tmpl, ctx,
-                                                 web.stripecount)),
+                                           args=(ctx, web.stripecount)),
         diffsummary=lambda **x: diffsummary(diffstatsgen),
         diffstat=diffstats,
         archives=web.archivelist(ctx.hex()),