Patchwork [2,of,6] hgweb: wrap {files} of changesetentry() with mappedgenerator

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

Comments

Yuya Nishihara - May 10, 2018, 2:16 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522765751 -32400
#      Tue Apr 03 23:29:11 2018 +0900
# Node ID 9dfcd4fe82f9e71aad3275df35a17232a889af07
# Parent  e732dac3aa0afd04b2192cbf723147e88f6a0d6f
hgweb: wrap {files} of changesetentry() with mappedgenerator

This can't be easily adapted to mappinggenerator because the associated
templates are switched per item.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -463,7 +463,7 @@  def symrevorshortnode(req, ctx):
     else:
         return short(ctx.node())
 
-def _listfilesgen(tmpl, ctx, stripecount):
+def _listfilesgen(context, tmpl, ctx, stripecount):
     parity = paritygen(stripecount)
     for blockno, f in enumerate(ctx.files()):
         template = 'filenodelink' if f in ctx else 'filenolink'
@@ -502,7 +502,9 @@  def changesetentry(web, ctx):
         changesettag=showtags,
         changesetbookmark=showbookmarks,
         changesetbranch=showbranch,
-        files=list(_listfilesgen(web.tmpl, ctx, web.stripecount)),
+        files=templateutil.mappedgenerator(_listfilesgen,
+                                           args=(web.tmpl, ctx,
+                                                 web.stripecount)),
         diffsummary=lambda **x: diffsummary(diffstatsgen),
         diffstat=diffstats,
         archives=web.archivelist(ctx.hex()),