Patchwork [2,of,7] hgweb: adapt {jsdata} of graph to mappinggenerator

login
register
mail settings
Submitter Yuya Nishihara
Date May 25, 2018, 1:54 p.m.
Message ID <7758a9a1f49b02dea023.1527256452@mimosa>
Download mbox | patch
Permalink /patch/31852/
State Accepted
Headers show

Comments

Yuya Nishihara - May 25, 2018, 1:54 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1522842372 -32400
#      Wed Apr 04 20:46:12 2018 +0900
# Node ID 7758a9a1f49b02dea023ab970e65af1874e6d636
# Parent  a2ff4a325229bd72a5447abe1efa3a2659fcc50b
hgweb: adapt {jsdata} of graph to mappinggenerator

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
@@ -1323,12 +1323,12 @@  def graph(web):
                         if item[1] == graphmod.CHANGESET)
         return tree
 
-    def jsdata():
-        return [{'node': pycompat.bytestr(ctx),
-                 'graphnode': webutil.getgraphnode(web.repo, ctx),
-                 'vertex': vtx,
-                 'edges': edges}
-                for (id, type, ctx, vtx, edges) in fulltree()]
+    def jsdata(context):
+        for (id, type, ctx, vtx, edges) in fulltree():
+            yield {'node': pycompat.bytestr(ctx),
+                   'graphnode': webutil.getgraphnode(web.repo, ctx),
+                   'vertex': vtx,
+                   'edges': edges}
 
     def nodes():
         parity = paritygen(web.stripecount)
@@ -1366,7 +1366,7 @@  def graph(web):
         bg_height=bg_height,
         changesets=count,
         nextentry=templateutil.mappinglist(nextentry),
-        jsdata=lambda **x: jsdata(),
+        jsdata=templateutil.mappinggenerator(jsdata),
         nodes=lambda **x: nodes(),
         node=ctx.hex(),
         changenav=changenav)