hgweb: adapt {jsdata} of graph to mappinggenerator
authorYuya Nishihara <yuya@tcha.org>
Wed, 04 Apr 2018 20:46:12 +0900
changeset 38209 215021e506e2
parent 38208 b10a9ace2738
child 38210 fb5803f4fb87
hgweb: adapt {jsdata} of graph to mappinggenerator The laziness is handled by the mappinggenerator class.
mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py	Wed Apr 04 20:44:18 2018 +0900
+++ b/mercurial/hgweb/webcommands.py	Wed Apr 04 20:46:12 2018 +0900
@@ -1323,12 +1323,12 @@
                         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 @@
         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)