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

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

Comments

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

Patch

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