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 Sun Apr 29 20:56:26 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,38 @@ 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 + bookmarks=webutil.nodebookmarksdict(web.repo, ctx.node()), 34 + branches=webutil.nodebranchdict(web.repo, ctx), 35 + inbranch=webutil.nodeinbranch(web.repo, ctx), 36 + tags=webutil.nodetagsdict(web.repo, ctx.node()), 37 + # convenience values for the canvas graph 38 + branchname=branch[0], 39 + branchtip=branch[1])) 40 + 41 + cols = max(cols, max([edge[0] for edge in edges] or [0]), 42 + max([edge[1] for edge in edges] or [0])) 43 + row += 1 44 45 return tmpl('graph', rev=rev, revcount=revcount, uprev=uprev, 46 lessvars=lessvars, morevars=morevars, downrev=downrev, 47 canvasheight=canvasheight, jsdata=data, bg_height=bg_height, 48 - node=revnode_hex, changenav=changenav) 49 + node=revnode_hex, changenav=changenav, 50 + rows=row, cols=cols, canvaswidth=(cols+1)*bg_height, 51 + truecanvasheight=row*bg_height) 52 53 def _getdoc(e): 54 doc = e[0].__doc__ 55 diff -r 55982f62651f mercurial/templates/raw/graph.tmpl 56 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 57 +++ b/mercurial/templates/raw/graph.tmpl Sun Apr 29 20:56:26 2012 +0200 58 @@ -0,0 +1,6 @@ 59 +{header} 60 +# HG graph 61 +# Node ID {node} 62 +# Rows shown {rows} 63 + 64 +{jsdata%graphnode} 65 diff -r 55982f62651f mercurial/templates/raw/graphedge.tmpl 66 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 67 +++ b/mercurial/templates/raw/graphedge.tmpl Sun Apr 29 20:56:26 2012 +0200 68 @@ -0,0 +1,1 @@ 69 +edge: ({col}, {row}) -> ({nextcol}, {nextrow}) (color {color}) 70 diff -r 55982f62651f mercurial/templates/raw/graphnode.tmpl 71 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 72 +++ b/mercurial/templates/raw/graphnode.tmpl Sun Apr 29 20:56:26 2012 +0200 73 @@ -0,0 +1,7 @@ 74 +changeset: {node} 75 +user: {user} 76 +date: {age} 77 +summary: {desc} 78 +{branches%branchname}{tags%tagname}{bookmarks%bookmarkname} 79 +node: ({col}, {row}) (color {color}) 80 +{edges%graphedge} 81 diff -r 55982f62651f mercurial/templates/raw/map 82 --- a/mercurial/templates/raw/map Wed Apr 18 01:20:16 2012 +0300 83 +++ b/mercurial/templates/raw/map Sun Apr 29 20:56:26 2012 +0200 84 @@ -28,3 +28,9 @@ 85 bookmarkentry = '{bookmark} {node}\n' 86 branches = '{entries%branchentry}' 87 branchentry = '{branch} {node} {status}\n' 88 +graph = graph.tmpl 89 +graphnode = graphnode.tmpl 90 +graphedge = graphedge.tmpl 91 +bookmarkname = 'bookmark: {name}\n' 92 +branchname = 'branch: {name}\n' 93 +tagname = 'tag: {name}\n' 94 diff -r 55982f62651f mercurial/templates/static/mercurial.js 95 --- a/mercurial/templates/static/mercurial.js Wed Apr 18 01:20:16 2012 +0300 96 +++ b/mercurial/templates/static/mercurial.js Sun Apr 29 20:56:26 2012 +0200 97 @@ -108,21 +108,22 @@ 98 this.bg[1] += this.bg_height; 99 100 var cur = data[i]; 101 - var node = cur[1]; 102 - var edges = cur[2]; 103 + var column = cur["col"]; 104 + var color; 105 + var edges = cur["edges"]; 106 var fold = false; 107 108 var prevWidth = this.ctx.lineWidth; 109 for (var j in edges) { 110 111 line = edges[j]; 112 - start = line[0]; 113 - end = line[1]; 114 - color = line[2]; 115 - var width = line[3]; 116 + start = line["col"]; 117 + end = line["nextcol"]; 118 + color = line["color"]; 119 + var width = line["width"]; 120 if(width < 0) 121 width = prevWidth; 122 - var branchcolor = line[4]; 123 + var branchcolor = line["bcolor"]; 124 if(branchcolor) 125 color = branchcolor; 126 127 @@ -146,13 +147,12 @@ 128 129 // Draw the revision node in the right column 130 131 - column = node[0] 132 - color = node[1] 133 + color = cur["color"]; 134 135 radius = this.box_size / 8; 136 x = this.cell[0] + this.box_size * column + this.box_size / 2; 137 y = this.bg[1] - this.bg_height / 2; 138 - var add = this.vertex(x, y, color, parity, cur); 139 + var add = this.vertexForEntry(x, y, color, parity, cur); 140 backgrounds += add[0]; 141 nodedata += add[1]; 142 143 @@ -165,6 +165,21 @@ 144 145 } 146 147 + this.vertexForEntry = function(x, y, color, parity, cur) { 148 + var tags = [], bookmarks = []; 149 + for (var i in cur["tags"]) { 150 + tags.push(cur["tags"][i]["name"]); 151 + } 152 + for (var i in cur["bookmarks"]) { 153 + bookmarks.push(cur["bookmarks"][i]["name"]); 154 + } 155 + return this.vertex(x, y, color, parity, [ 156 + cur["node"], [cur["col"], cur["color"]], 157 + cur["edges"], cur["desc"], cur["user"], cur["age"], 158 + [cur["branchname"], cur["branchtip"]], 159 + tags, bookmarks 160 + ]) 161 + } 162 } 163 164 165 diff -r 55982f62651f tests/test-hgweb-commands.t 166 --- a/tests/test-hgweb-commands.t Wed Apr 18 01:20:16 2012 +0300 167 +++ b/tests/test-hgweb-commands.t Sun Apr 29 20:56:26 2012 +0200 168 @@ -957,7 +957,7 @@ 169 <script> 170 <!-- hide script content 171 172 - 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"]]]; 173 + 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}]; 174 var graph = new Graph(); 175 graph.scale(39); 176 177 @@ -1037,6 +1037,56 @@ 178 </div> 179 </body> 180 </html> 181 + 182 + 183 +raw graph 184 + 185 + $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/graph/?style=raw' 186 + 200 Script output follows 187 + 188 + 189 + # HG graph 190 + # Node ID ba87b23d29ca67a305625d81a20ac279c1e3f444 191 + # Rows shown 4 192 + 193 + changeset: ba87b23d29ca 194 + user: test 195 + date: 1970-01-01 196 + summary: branch 197 + branch: unstable 198 + tag: tip 199 + bookmark: something 200 + 201 + node: (0, 0) (color 1) 202 + edge: (0, 0) -> (0, 1) (color 1) 203 + 204 + changeset: 1d22e65f027e 205 + user: test 206 + date: 1970-01-01 207 + summary: branch 208 + branch: stable 209 + 210 + node: (0, 1) (color 1) 211 + edge: (0, 1) -> (0, 2) (color 1) 212 + 213 + changeset: a4f92ed23982 214 + user: test 215 + date: 1970-01-01 216 + summary: Added tag 1.0 for changeset 2ef0ac749a14 217 + branch: default 218 + 219 + node: (0, 2) (color 1) 220 + edge: (0, 2) -> (0, 3) (color 1) 221 + 222 + changeset: 2ef0ac749a14 223 + user: test 224 + date: 1970-01-01 225 + summary: base 226 + tag: 1.0 227 + bookmark: anotherthing 228 + 229 + node: (0, 3) (color 1) 230 + 231 232 233 capabilities 234 @@ -1214,7 +1264,7 @@ 235 236 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/graph/' \ 237 > | grep '^var data =' 238 - 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"]]]; 239 + 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}]; 240 241 capabilities 242