comparison mercurial/hgweb/webcommands.py @ 38221:215021e506e2

hgweb: adapt {jsdata} of graph to mappinggenerator The laziness is handled by the mappinggenerator class.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 04 Apr 2018 20:46:12 +0900
parents b10a9ace2738
children fb5803f4fb87
comparison
equal deleted inserted replaced
38220:b10a9ace2738 38221:215021e506e2
1321 dag = graphmod.dagwalker(web.repo, smartset.baseset(revs)) 1321 dag = graphmod.dagwalker(web.repo, smartset.baseset(revs))
1322 tree = list(item for item in graphmod.colored(dag, web.repo) 1322 tree = list(item for item in graphmod.colored(dag, web.repo)
1323 if item[1] == graphmod.CHANGESET) 1323 if item[1] == graphmod.CHANGESET)
1324 return tree 1324 return tree
1325 1325
1326 def jsdata(): 1326 def jsdata(context):
1327 return [{'node': pycompat.bytestr(ctx), 1327 for (id, type, ctx, vtx, edges) in fulltree():
1328 'graphnode': webutil.getgraphnode(web.repo, ctx), 1328 yield {'node': pycompat.bytestr(ctx),
1329 'vertex': vtx, 1329 'graphnode': webutil.getgraphnode(web.repo, ctx),
1330 'edges': edges} 1330 'vertex': vtx,
1331 for (id, type, ctx, vtx, edges) in fulltree()] 1331 'edges': edges}
1332 1332
1333 def nodes(): 1333 def nodes():
1334 parity = paritygen(web.stripecount) 1334 parity = paritygen(web.stripecount)
1335 for row, (id, type, ctx, vtx, edges) in enumerate(tree): 1335 for row, (id, type, ctx, vtx, edges) in enumerate(tree):
1336 entry = webutil.commonentry(web.repo, ctx) 1336 entry = webutil.commonentry(web.repo, ctx)
1364 graphvars=graphvars, 1364 graphvars=graphvars,
1365 rows=rows, 1365 rows=rows,
1366 bg_height=bg_height, 1366 bg_height=bg_height,
1367 changesets=count, 1367 changesets=count,
1368 nextentry=templateutil.mappinglist(nextentry), 1368 nextentry=templateutil.mappinglist(nextentry),
1369 jsdata=lambda **x: jsdata(), 1369 jsdata=templateutil.mappinggenerator(jsdata),
1370 nodes=lambda **x: nodes(), 1370 nodes=lambda **x: nodes(),
1371 node=ctx.hex(), 1371 node=ctx.hex(),
1372 changenav=changenav) 1372 changenav=changenav)
1373 1373
1374 def _getdoc(e): 1374 def _getdoc(e):