# HG changeset patch # User Paul Boddie # Date 1335566128 -7200 # Node ID 84c2b3fdf0b92228810457528bc8400caf5bde5d # Parent ddde4ba0f47a3d83db3b47fe0ab36d657cdd04e9 Changed the graph template to use unified graph data as provided by the accompanying patch. diff -r ddde4ba0f47a -r 84c2b3fdf0b9 patches/patch-hgweb-graph-data.diff --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/patch-hgweb-graph-data.diff Sat Apr 28 00:35:28 2012 +0200 @@ -0,0 +1,125 @@ +diff -r 55982f62651f mercurial/hgweb/webcommands.py +--- a/mercurial/hgweb/webcommands.py Wed Apr 18 01:20:16 2012 +0300 ++++ b/mercurial/hgweb/webcommands.py Sat Apr 28 00:34:29 2012 +0200 +@@ -785,7 +785,8 @@ + tree = list(graphmod.colored(dag, web.repo)) + canvasheight = (len(tree) + 1) * bg_height - 27 + data = [] +- for (id, type, ctx, vtx, edges) in tree: ++ cols = 0 ++ for row, (id, type, ctx, vtx, edges) in enumerate(tree): + if type != graphmod.CHANGESET: + continue + node = str(ctx) +@@ -795,13 +796,37 @@ + user = cgi.escape(templatefilters.person(ctx.user())) + branch = ctx.branch() + branch = branch, web.repo.branchtags().get(branch) == ctx.node() +- data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), +- ctx.bookmarks())) ++ ++ edgedata = [dict(col=edge[0], nextcol=edge[1], ++ color=(edge[2] - 1) % 6 + 1, ++ width=edge[3], bcolor=edge[4]) for edge in edges] ++ ++ data.append(dict(node=node, ++ col=vtx[0], ++ color=(vtx[1] - 1) % 6 + 1, ++ edges=edgedata, ++ row=row, ++ nextrow=row+1, ++ bg_height=bg_height, ++ desc=desc, ++ user=user, ++ age=age, ++ branchname=branch[0], ++ branchtip=branch[1], ++ bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), ++ branches=webutil.nodebranchdict(web.repo, ctx), ++ inbranch=webutil.nodeinbranch(web.repo, ctx), ++ tags=webutil.nodetagsdict(web.repo, ctx.node()))) ++ ++ cols = max(cols, max([edge[0] for edge in edges] or [0]), ++ max([edge[1] for edge in edges] or [0])) + + return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev, + lessvars=lessvars, morevars=morevars, downrev=downrev, + canvasheight=canvasheight, jsdata=data, bg_height=bg_height, +- node=revnode_hex, changenav=changenav) ++ node=revnode_hex, changenav=changenav, ++ rows=row+1, cols=cols, canvaswidth=(cols+1)*bg_height, ++ truecanvasheight=(row+1)*bg_height) + + def _getdoc(e): + doc = e[0].__doc__ +diff -r 55982f62651f mercurial/templates/static/mercurial.js +--- a/mercurial/templates/static/mercurial.js Wed Apr 18 01:20:16 2012 +0300 ++++ b/mercurial/templates/static/mercurial.js Sat Apr 28 00:34:29 2012 +0200 +@@ -108,21 +108,22 @@ + this.bg[1] += this.bg_height; + + var cur = data[i]; +- var node = cur[1]; +- var edges = cur[2]; ++ var column = cur["col"]; ++ var color; ++ var edges = cur["edges"]; + var fold = false; + + var prevWidth = this.ctx.lineWidth; + for (var j in edges) { + + line = edges[j]; +- start = line[0]; +- end = line[1]; +- color = line[2]; +- var width = line[3]; ++ start = line["col"]; ++ end = line["nextcol"]; ++ color = line["color"]; ++ var width = line["width"]; + if(width < 0) + width = prevWidth; +- var branchcolor = line[4]; ++ var branchcolor = line["bcolor"]; + if(branchcolor) + color = branchcolor; + +@@ -146,13 +147,12 @@ + + // Draw the revision node in the right column + +- column = node[0] +- color = node[1] ++ color = cur["color"]; + + radius = this.box_size / 8; + x = this.cell[0] + this.box_size * column + this.box_size / 2; + y = this.bg[1] - this.bg_height / 2; +- var add = this.vertex(x, y, color, parity, cur); ++ var add = this.vertexForEntry(x, y, color, parity, cur); + backgrounds += add[0]; + nodedata += add[1]; + +@@ -165,6 +165,21 @@ + + } + ++ this.vertexForEntry = function(x, y, color, parity, cur) { ++ var tags = [], bookmarks = []; ++ for (var i in cur["tags"]) { ++ tags.push(cur["tags"][i]["name"]); ++ } ++ for (var i in cur["bookmarks"]) { ++ bookmarks.push(cur["bookmarks"][i]["name"]); ++ } ++ return this.vertex(x, y, color, parity, [ ++ cur["node"], [cur["col"], cur["color"]], ++ cur["edges"], cur["desc"], cur["user"], cur["age"], ++ [cur["branchname"], cur["branchtip"]], ++ tags, bookmarks ++ ]) ++ } + } + + diff -r ddde4ba0f47a -r 84c2b3fdf0b9 patches/patch-hgweb-webcommands-SVG.diff --- a/patches/patch-hgweb-webcommands-SVG.diff Fri Dec 02 00:26:18 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -# HG changeset patch -# User Paul Boddie -# Date 1322607302 -3600 -# Node ID 160b604c1b8f8066976e86c63ece2062f075d1b6 -# Parent ad686c818e1c7d5ed0335327321003ba8ea04664 -hgweb: Provide SVG-related data to the output of the graph command - -diff -r ad686c818e1c -r 160b604c1b8f mercurial/hgweb/webcommands.py ---- a/mercurial/hgweb/webcommands.py Fri Nov 25 02:11:12 2011 +0100 -+++ b/mercurial/hgweb/webcommands.py Tue Nov 29 23:55:02 2011 +0100 -@@ -772,6 +772,9 @@ - tree = list(graphmod.colored(dag)) - canvasheight = (len(tree) + 1) * bg_height - 27 - data = [] -+ svgdata = [] -+ row = 0 -+ cols = 0 - for (id, type, ctx, vtx, edges) in tree: - if type != graphmod.CHANGESET: - continue -@@ -784,11 +787,30 @@ - branch = branch, web.repo.branchtags().get(branch) == ctx.node() - data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), - ctx.bookmarks())) -+ svgdata.append(dict( -+ node=node, -+ col=vtx[0], -+ color=(vtx[1] - 1) % 6 + 1, -+ edges=[dict(col=edge[0], nextcol=edge[1], color=(edge[2] - 1) % 6 + 1) for edge in edges], -+ row=row, -+ nextrow=row+1, -+ bg_height=bg_height, -+ desc=desc, -+ user=user, -+ age=age, -+ bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), -+ branches=webutil.nodebranchdict(web.repo, ctx), -+ inbranch=webutil.nodeinbranch(web.repo, ctx), -+ tags=webutil.nodetagsdict(web.repo, ctx.node()))) -+ row += 1 -+ cols = max(cols, max([edge[0] for edge in edges] or [0]), max([edge[1] for edge in edges] or [0])) - - return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev, - lessvars=lessvars, morevars=morevars, downrev=downrev, - canvasheight=canvasheight, jsdata=data, bg_height=bg_height, -- node=revnode_hex, changenav=changenav) -+ node=revnode_hex, changenav=changenav, svgdata=svgdata, -+ rows=row, cols=cols, canvaswidth=(cols+1)*bg_height, -+ truecanvasheight=row*bg_height) - - def _getdoc(e): - doc = e[0].__doc__ diff -r ddde4ba0f47a -r 84c2b3fdf0b9 patches/patch-hgweb-webcommands-blockno.diff --- a/patches/patch-hgweb-webcommands-blockno.diff Fri Dec 02 00:26:18 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -# HG changeset patch -# User Paul Boddie -# Date 1322607647 -3600 -# Node ID 387585e3105efc9df33e947527950ced65320201 -# Parent ad686c818e1c7d5ed0335327321003ba8ea04664 -hgweb: Introduce a blockno variable in the changeset's files list and in the diffs webcommand - -diff -r ad686c818e1c -r 387585e3105e mercurial/hgweb/webcommands.py ---- a/mercurial/hgweb/webcommands.py Fri Nov 25 02:11:12 2011 +0100 -+++ b/mercurial/hgweb/webcommands.py Wed Nov 30 00:00:47 2011 +0100 -@@ -261,10 +261,10 @@ - - files = [] - parity = paritygen(web.stripecount) -- for f in ctx.files(): -+ for blockno, f in enumerate(ctx.files()): - template = f in ctx and 'filenodelink' or 'filenolink' - files.append(tmpl(template, -- node=ctx.hex(), file=f, -+ node=ctx.hex(), file=f, blockno=blockno+1, - parity=parity.next())) - - style = web.config('web', 'style', 'paper') -diff -r ad686c818e1c -r 387585e3105e mercurial/hgweb/webutil.py ---- a/mercurial/hgweb/webutil.py Fri Nov 25 02:11:12 2011 +0100 -+++ b/mercurial/hgweb/webutil.py Wed Nov 30 00:00:47 2011 +0100 -@@ -173,8 +173,7 @@ - start += 1 - - blockcount = countgen() -- def prettyprintlines(diff): -- blockno = blockcount.next() -+ def prettyprintlines(diff, blockno): - for lineno, l in enumerate(diff.splitlines(True)): - lineno = "%d.%d" % (blockno, lineno + 1) - if l.startswith('+'): -@@ -203,14 +202,16 @@ - block = [] - for chunk in patch.diff(repo, node1, node2, m, opts=diffopts): - if chunk.startswith('diff') and block: -- yield tmpl('diffblock', parity=parity.next(), -- lines=prettyprintlines(''.join(block))) -+ blockno = blockcount.next() -+ yield tmpl('diffblock', parity=parity.next(), blockno=blockno, -+ lines=prettyprintlines(''.join(block), blockno)) - block = [] - if chunk.startswith('diff') and style != 'raw': - chunk = ''.join(chunk.splitlines(True)[1:]) - block.append(chunk) -- yield tmpl('diffblock', parity=parity.next(), -- lines=prettyprintlines(''.join(block))) -+ blockno = blockcount.next() -+ yield tmpl('diffblock', parity=parity.next(), blockno=blockno, -+ lines=prettyprintlines(''.join(block), blockno)) - - def diffstatgen(ctx): - '''Generator function that provides the diffstat data.''' diff -r ddde4ba0f47a -r 84c2b3fdf0b9 themes/mercurialweb/graph.tmpl --- a/themes/mercurialweb/graph.tmpl Fri Dec 02 00:26:18 2011 +0100 +++ b/themes/mercurialweb/graph.tmpl Sat Apr 28 00:35:28 2012 +0200 @@ -36,13 +36,13 @@
-{svgdata%graphlabel} +{jsdata%graphlabel}
-{svgdata%graphnode} +{jsdata%graphnode}