Patchwork [2,of,7] hgweb: wrap {changelogtag}, {changesettag}, and {changesetbookmark}

login
register
mail settings
Submitter Yuya Nishihara
Date May 9, 2018, 1:33 p.m.
Message ID <7736022cdd5f377a9319.1525872783@mimosa>
Download mbox | patch
Permalink /patch/31428/
State Accepted
Headers show

Comments

Yuya Nishihara - May 9, 2018, 1:33 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522597166 -32400
#      Mon Apr 02 00:39:26 2018 +0900
# Node ID 7736022cdd5f377a93196e02f07f2c59c8b78151
# Parent  7476d31f604a6ffa986725960bb34a85f1158f82
hgweb: wrap {changelogtag}, {changesettag}, and {changesetbookmark}

These can't be hybrid lists as they've associated with named template, 't1'.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -274,15 +274,17 @@  def nodebranchnodefault(ctx):
         branches.append(branch)
     return templateutil.hybridlist(branches, name='name')
 
+def _nodenamesgen(context, f, node, name):
+    for t in f(node):
+        yield {name: t}
+
 def showtag(repo, tmpl, t1, node=nullid):
-    for t in repo.nodetags(node):
-        lm = {'tag': t}
-        yield tmpl.generate(t1, lm)
+    args = (repo.nodetags, node, 'tag')
+    return templateutil.mappinggenerator(_nodenamesgen, args=args, name=t1)
 
 def showbookmark(repo, tmpl, t1, node=nullid):
-    for t in repo.nodebookmarks(node):
-        lm = {'bookmark': t}
-        yield tmpl.generate(t1, lm)
+    args = (repo.nodebookmarks, node, 'bookmark')
+    return templateutil.mappinggenerator(_nodenamesgen, args=args, name=t1)
 
 def branchentries(repo, stripecount, limit=0):
     tips = []