1 # HG changeset patch 2 # User Paul Boddie <paul@boddie.org.uk> 3 # Date 1322607302 -3600 4 # Node ID 160b604c1b8f8066976e86c63ece2062f075d1b6 5 # Parent ad686c818e1c7d5ed0335327321003ba8ea04664 6 hgweb: Provide SVG-related data to the output of the graph command 7 8 diff -r ad686c818e1c -r 160b604c1b8f mercurial/hgweb/webcommands.py 9 --- a/mercurial/hgweb/webcommands.py Fri Nov 25 02:11:12 2011 +0100 10 +++ b/mercurial/hgweb/webcommands.py Tue Nov 29 23:55:02 2011 +0100 11 @@ -772,6 +772,9 @@ 12 tree = list(graphmod.colored(dag)) 13 canvasheight = (len(tree) + 1) * bg_height - 27 14 data = [] 15 + svgdata = [] 16 + row = 0 17 + cols = 0 18 for (id, type, ctx, vtx, edges) in tree: 19 if type != graphmod.CHANGESET: 20 continue 21 @@ -784,11 +787,30 @@ 22 branch = branch, web.repo.branchtags().get(branch) == ctx.node() 23 data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), 24 ctx.bookmarks())) 25 + svgdata.append(dict( 26 + node=node, 27 + col=vtx[0], 28 + color=(vtx[1] - 1) % 6 + 1, 29 + edges=[dict(col=edge[0], nextcol=edge[1], color=(edge[2] - 1) % 6 + 1) for edge in edges], 30 + row=row, 31 + nextrow=row+1, 32 + bg_height=bg_height, 33 + desc=desc, 34 + user=user, 35 + age=age, 36 + bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), 37 + branches=webutil.nodebranchdict(web.repo, ctx), 38 + inbranch=webutil.nodeinbranch(web.repo, ctx), 39 + tags=webutil.nodetagsdict(web.repo, ctx.node()))) 40 + row += 1 41 + cols = max(cols, max([edge[0] for edge in edges] or [0]), max([edge[1] for edge in edges] or [0])) 42 43 return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev, 44 lessvars=lessvars, morevars=morevars, downrev=downrev, 45 canvasheight=canvasheight, jsdata=data, bg_height=bg_height, 46 - node=revnode_hex, changenav=changenav) 47 + node=revnode_hex, changenav=changenav, svgdata=svgdata, 48 + rows=row, cols=cols, canvaswidth=(cols+1)*bg_height, 49 + truecanvasheight=row*bg_height) 50 51 def _getdoc(e): 52 doc = e[0].__doc__