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