Patchwork [10,of,22,V2-Series-D] hgweb: simplify return value creation in for navgen

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 14, 2013, 8:35 p.m.
Message ID <4f2c81e46f4619341d1d.1358195742@yamac.lan>
Download mbox | patch
Permalink /patch/606/
State Accepted
Commit 083daee1b7492cac49bdcd348f1dc632624f1257
Headers show

Comments

Pierre-Yves David - Jan. 14, 2013, 8:35 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1358178755 -3600
# Node ID 4f2c81e46f4619341d1d980f550c011adfa90ebe
# Parent  0e1549221853543dc811b2e6e70f8f772ac570a3
hgweb: simplify return value creation in for navgen

We now have access to better syntax allowing a clearer version.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -80,17 +80,13 @@  class revnav(object):
         try:
             navbefore.insert(0, ("(0)", self.hex(0)))
         except error.RepoError:
             pass
 
-        def gen(l):
-            def f(**map):
-                for label, node in l:
-                    yield {"label": label, "node": node}
-            return f
-
-        return (dict(before=gen(navbefore), after=gen(navafter)),)
+        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)},)
 
 def _siblings(siblings=[], hiderev=None):
     siblings = [s for s in siblings if s.node() != nullid]
     if len(siblings) == 1 and siblings[0].rev() == hiderev:
         return