Patchwork [7,of,7] hgweb: wrap {entries}* of tags with mappinggenerator

login
register
mail settings
Submitter Yuya Nishihara
Date May 13, 2018, 3:20 a.m.
Message ID <972fb3ad116dfe162a56.1526181604@mimosa>
Download mbox | patch
Permalink /patch/31575/
State Accepted
Headers show

Comments

Yuya Nishihara - May 13, 2018, 3:20 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522840708 -32400
#      Wed Apr 04 20:18:28 2018 +0900
# Node ID 972fb3ad116dfe162a566e21c014ae951d4dfa27
# Parent  a4560b4d1b0ea2d1c81e0ac0baca0e0ce2070557
hgweb: wrap {entries}* of tags with mappinggenerator

They were functions returning a generator of mappings. The laziness is
handled by the mappinggenerator class.

Patch

diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -617,7 +617,7 @@  def tags(web):
     i = list(reversed(web.repo.tagslist()))
     parity = paritygen(web.stripecount)
 
-    def entries(notip, latestonly, **map):
+    def entries(context, notip, latestonly):
         t = i
         if notip:
             t = [(k, n) for k, n in i if k != "tip"]
@@ -632,9 +632,10 @@  def tags(web):
     return web.sendtemplate(
         'tags',
         node=hex(web.repo.changelog.tip()),
-        entries=lambda **x: entries(False, False, **x),
-        entriesnotip=lambda **x: entries(True, False, **x),
-        latestentry=lambda **x: entries(True, True, **x))
+        entries=templateutil.mappinggenerator(entries, args=(False, False)),
+        entriesnotip=templateutil.mappinggenerator(entries,
+                                                   args=(True, False)),
+        latestentry=templateutil.mappinggenerator(entries, args=(True, True)))
 
 @webcommand('bookmarks')
 def bookmarks(web):