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