1 diff -r 55982f62651f mercurial/hgweb/webcommands.py 2 --- a/mercurial/hgweb/webcommands.py Wed Apr 18 01:20:16 2012 +0300 3 +++ b/mercurial/hgweb/webcommands.py Sat Apr 28 01:32:46 2012 +0200 4 @@ -785,6 +785,8 @@ 5 tree = list(graphmod.colored(dag, web.repo)) 6 canvasheight = (len(tree) + 1) * bg_height - 27 7 data = [] 8 + cols = 0 9 + row = 0 10 for (id, type, ctx, vtx, edges) in tree: 11 if type != graphmod.CHANGESET: 12 continue 13 @@ -795,13 +797,37 @@ 14 user = cgi.escape(templatefilters.person(ctx.user())) 15 branch = ctx.branch() 16 branch = branch, web.repo.branchtags().get(branch) == ctx.node() 17 - data.append((node, vtx, edges, desc, user, age, branch, ctx.tags(), 18 - ctx.bookmarks())) 19 + 20 + edgedata = [dict(col=edge[0], nextcol=edge[1], 21 + color=(edge[2] - 1) % 6 + 1, 22 + width=edge[3], bcolor=edge[4]) for edge in edges] 23 + 24 + data.append(dict(node=node, 25 + col=vtx[0], 26 + color=(vtx[1] - 1) % 6 + 1, 27 + edges=edgedata, 28 + row=row, 29 + nextrow=row+1, 30 + desc=desc, 31 + user=user, 32 + age=age, 33 + branchname=branch[0], 34 + branchtip=branch[1], 35 + bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), 36 + branches=webutil.nodebranchdict(web.repo, ctx), 37 + inbranch=webutil.nodeinbranch(web.repo, ctx), 38 + tags=webutil.nodetagsdict(web.repo, ctx.node()))) 39 + 40 + cols = max(cols, max([edge[0] for edge in edges] or [0]), 41 + max([edge[1] for edge in edges] or [0])) 42 + row += 1 43 44 return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev, 45 lessvars=lessvars, morevars=morevars, downrev=downrev, 46 canvasheight=canvasheight, jsdata=data, bg_height=bg_height, 47 - node=revnode_hex, changenav=changenav) 48 + node=revnode_hex, changenav=changenav, 49 + rows=row, cols=cols, canvaswidth=(cols+1)*bg_height, 50 + truecanvasheight=row*bg_height) 51 52 def _getdoc(e): 53 doc = e[0].__doc__ 54 diff -r 55982f62651f mercurial/templates/static/mercurial.js 55 --- a/mercurial/templates/static/mercurial.js Wed Apr 18 01:20:16 2012 +0300 56 +++ b/mercurial/templates/static/mercurial.js Sat Apr 28 01:32:46 2012 +0200 57 @@ -108,21 +108,22 @@ 58 this.bg[1] += this.bg_height; 59 60 var cur = data[i]; 61 - var node = cur[1]; 62 - var edges = cur[2]; 63 + var column = cur["col"]; 64 + var color; 65 + var edges = cur["edges"]; 66 var fold = false; 67 68 var prevWidth = this.ctx.lineWidth; 69 for (var j in edges) { 70 71 line = edges[j]; 72 - start = line[0]; 73 - end = line[1]; 74 - color = line[2]; 75 - var width = line[3]; 76 + start = line["col"]; 77 + end = line["nextcol"]; 78 + color = line["color"]; 79 + var width = line["width"]; 80 if(width < 0) 81 width = prevWidth; 82 - var branchcolor = line[4]; 83 + var branchcolor = line["bcolor"]; 84 if(branchcolor) 85 color = branchcolor; 86 87 @@ -146,13 +147,12 @@ 88 89 // Draw the revision node in the right column 90 91 - column = node[0] 92 - color = node[1] 93 + color = cur["color"]; 94 95 radius = this.box_size / 8; 96 x = this.cell[0] + this.box_size * column + this.box_size / 2; 97 y = this.bg[1] - this.bg_height / 2; 98 - var add = this.vertex(x, y, color, parity, cur); 99 + var add = this.vertexForEntry(x, y, color, parity, cur); 100 backgrounds += add[0]; 101 nodedata += add[1]; 102 103 @@ -165,6 +165,21 @@ 104 105 } 106 107 + this.vertexForEntry = function(x, y, color, parity, cur) { 108 + var tags = [], bookmarks = []; 109 + for (var i in cur["tags"]) { 110 + tags.push(cur["tags"][i]["name"]); 111 + } 112 + for (var i in cur["bookmarks"]) { 113 + bookmarks.push(cur["bookmarks"][i]["name"]); 114 + } 115 + return this.vertex(x, y, color, parity, [ 116 + cur["node"], [cur["col"], cur["color"]], 117 + cur["edges"], cur["desc"], cur["user"], cur["age"], 118 + [cur["branchname"], cur["branchtip"]], 119 + tags, bookmarks 120 + ]) 121 + } 122 } 123 124 125 diff -r 55982f62651f tests/test-hgweb-commands.t 126 --- a/tests/test-hgweb-commands.t Wed Apr 18 01:20:16 2012 +0300 127 +++ b/tests/test-hgweb-commands.t Sat Apr 28 01:32:46 2012 +0200 128 @@ -957,7 +957,7 @@ 129 <script> 130 <!-- hide script content 131 132 - var data = [["ba87b23d29ca", [0, 1], [[0, 0, 1, 3, "FF0000"]], "branch", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["1d22e65f027e", [0, 1], [[0, 0, 1, 3, ""]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, 3, ""]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]]; 133 + var data = [{"node": "ba87b23d29ca", "branches": [{"name": "unstable"}], "desc": "branch", "tags": [{"name": "tip"}], "color": 1, "age": "1970-01-01", "inbranch": [], "nextrow": 1, "edges": [{"color": 1, "width": 3, "nextcol": 0, "bcolor": "FF0000", "col": 0}], "user": "test", "branchtip": true, "bookmarks": [{"name": "something"}], "branchname": "unstable", "col": 0, "row": 0}, {"node": "1d22e65f027e", "branches": [{"name": "stable"}], "desc": "branch", "tags": [], "color": 1, "age": "1970-01-01", "inbranch": [], "nextrow": 2, "edges": [{"color": 1, "width": 3, "nextcol": 0, "bcolor": "", "col": 0}], "user": "test", "branchtip": true, "bookmarks": [], "branchname": "stable", "col": 0, "row": 1}, {"node": "a4f92ed23982", "branches": [{"name": "default"}], "desc": "Added tag 1.0 for changeset 2ef0ac749a14", "tags": [], "color": 1, "age": "1970-01-01", "inbranch": [], "nextrow": 3, "edges": [{"color": 1, "width": 3, "nextcol": 0, "bcolor": "", "col": 0}], "user": "test", "branchtip": true, "bookmarks": [], "branchname": "default", "col": 0, "row": 2}, {"node": "2ef0ac749a14", "branches": [], "desc": "base", "tags": [{"name": "1.0"}], "color": 1, "age": "1970-01-01", "inbranch": [], "nextrow": 4, "edges": [], "user": "test", "branchtip": false, "bookmarks": [{"name": "anotherthing"}], "branchname": "default", "col": 0, "row": 3}]; 134 var graph = new Graph(); 135 graph.scale(39); 136 137 @@ -1214,7 +1214,7 @@ 138 139 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/graph/' \ 140 > | grep '^var data =' 141 - var data = [["548001d11f45", [0, 1], [[0, 0, 1, -1, ""]], "\u80fd", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["ba87b23d29ca", [0, 1], [[0, 0, 1, 3, "FF0000"]], "branch", "test", "1970-01-01", ["unstable", false], [], []], ["1d22e65f027e", [0, 1], [[0, 0, 1, 3, ""]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, 3, ""]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]]; 142 + var data = [{"node": "548001d11f45", "branches": [{"name": "unstable"}], "desc": "\u80fd", "tags": [{"name": "tip"}], "color": 1, "age": "1970-01-01", "inbranch": [], "nextrow": 1, "edges": [{"color": 1, "width": -1, "nextcol": 0, "bcolor": "", "col": 0}], "user": "test", "branchtip": true, "bookmarks": [{"name": "something"}], "branchname": "unstable", "col": 0, "row": 0}, {"node": "ba87b23d29ca", "branches": [], "desc": "branch", "tags": [], "color": 1, "age": "1970-01-01", "inbranch": [{"name": "unstable"}], "nextrow": 2, "edges": [{"color": 1, "width": 3, "nextcol": 0, "bcolor": "FF0000", "col": 0}], "user": "test", "branchtip": false, "bookmarks": [], "branchname": "unstable", "col": 0, "row": 1}, {"node": "1d22e65f027e", "branches": [{"name": "stable"}], "desc": "branch", "tags": [], "color": 1, "age": "1970-01-01", "inbranch": [], "nextrow": 3, "edges": [{"color": 1, "width": 3, "nextcol": 0, "bcolor": "", "col": 0}], "user": "test", "branchtip": true, "bookmarks": [], "branchname": "stable", "col": 0, "row": 2}, {"node": "a4f92ed23982", "branches": [{"name": "default"}], "desc": "Added tag 1.0 for changeset 2ef0ac749a14", "tags": [], "color": 1, "age": "1970-01-01", "inbranch": [], "nextrow": 4, "edges": [{"color": 1, "width": 3, "nextcol": 0, "bcolor": "", "col": 0}], "user": "test", "branchtip": true, "bookmarks": [], "branchname": "default", "col": 0, "row": 3}, {"node": "2ef0ac749a14", "branches": [], "desc": "base", "tags": [{"name": "1.0"}], "color": 1, "age": "1970-01-01", "inbranch": [], "nextrow": 5, "edges": [], "user": "test", "branchtip": false, "bookmarks": [{"name": "anotherthing"}], "branchname": "default", "col": 0, "row": 4}]; 143 144 capabilities 145