Patchwork [4,of,7] hgweb: make revnav.gen() simply build a list of mappings by one pass

login
register
mail settings
Submitter Yuya Nishihara
Date April 14, 2018, 12:49 p.m.
Message ID <ec55e9ef2255378a190b.1523710154@mimosa>
Download mbox | patch
Permalink /patch/31024/
State Accepted
Headers show

Comments

Yuya Nishihara - April 14, 2018, 12:49 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522593269 -32400
#      Sun Apr 01 23:34:29 2018 +0900
# Node ID ec55e9ef2255378a190bdda6f060dca23659cc9d
# Parent  b7742898a29d79f01beb36c1cedd58acfdab05ab
hgweb: make revnav.gen() simply build a list of mappings by one pass

There was actually no lazy stuff.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -127,8 +127,7 @@  class revnav(object):
         The return is:
             - a single element tuple
             - containing a dictionary with a `before` and `after` key
-            - values are generator functions taking arbitrary number of kwargs
-            - yield items are dictionaries with `label` and `node` keys
+            - values are dictionaries with `label` and `node` keys
         """
         if not self:
             # empty repo
@@ -143,22 +142,21 @@  class revnav(object):
         targets.sort()
 
         first = self._first()
-        navbefore = [("(%i)" % first, self.hex(first))]
+        navbefore = [{'label': '(%i)' % first, 'node': self.hex(first)}]
         navafter = []
         for rev in targets:
             if rev not in self._revlog:
                 continue
             if pos < rev < limit:
-                navafter.append(("+%d" % abs(rev - pos), self.hex(rev)))
+                navafter.append({'label': '+%d' % abs(rev - pos),
+                                 'node': self.hex(rev)})
             if 0 < rev < pos:
-                navbefore.append(("-%d" % abs(rev - pos), self.hex(rev)))
-
+                navbefore.append({'label': '-%d' % abs(rev - pos),
+                                  'node': self.hex(rev)})
 
-        navafter.append(("tip", "tip"))
+        navafter.append({'label': 'tip', 'node': 'tip'})
 
-        data = lambda i: {"label": i[0], "node": i[1]}
-        return ({'before': lambda **map: (data(i) for i in navbefore),
-                 'after':  lambda **map: (data(i) for i in navafter)},)
+        return ({'before': navbefore, 'after': navafter},)
 
 class filerevnav(revnav):