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