##// END OF EJS Templates
Revision graph sometimes broken (#11612)....
Jean-Philippe Lang -
r10186:745c5d053e0d
parent child
Show More
@@ -1,88 +1,94
1 var revisionGraph = null;
1 var revisionGraph = null;
2
2
3 function drawRevisionGraph(holder, commits_hash, graph_space) {
3 function drawRevisionGraph(holder, commits_hash, graph_space) {
4 var XSTEP = 20,
4 var XSTEP = 20,
5 CIRCLE_INROW_OFFSET = 10;
5 CIRCLE_INROW_OFFSET = 10;
6 var commits_by_scmid = commits_hash,
6 var commits_by_scmid = commits_hash,
7 commits = $.map(commits_by_scmid, function(val,i){return val;});
7 commits = $.map(commits_by_scmid, function(val,i){return val;});
8 var max_rdmid = commits.length - 1;
8 var max_rdmid = commits.length - 1;
9 var commit_table_rows = $('table.changesets tr.changeset');
9 var commit_table_rows = $('table.changesets tr.changeset');
10
10
11 // create graph
11 // create graph
12 if(revisionGraph != null)
12 if(revisionGraph != null)
13 revisionGraph.clear();
13 revisionGraph.clear();
14 else
14 else
15 revisionGraph = Raphael(holder);
15 revisionGraph = Raphael(holder);
16
16
17 var top = revisionGraph.set();
17 var top = revisionGraph.set();
18 // init dimensions
18 // init dimensions
19 var graph_x_offset = commit_table_rows.first().find('td').first().position().left - $(holder).position().left,
19 var graph_x_offset = commit_table_rows.first().find('td').first().position().left - $(holder).position().left,
20 graph_y_offset = $(holder).position().top,
20 graph_y_offset = $(holder).position().top,
21 graph_right_side = graph_x_offset + (graph_space + 1) * XSTEP,
21 graph_right_side = graph_x_offset + (graph_space + 1) * XSTEP,
22 graph_bottom = commit_table_rows.last().position().top + commit_table_rows.last().height() - graph_y_offset;
22 graph_bottom = commit_table_rows.last().position().top + commit_table_rows.last().height() - graph_y_offset;
23
23
24 revisionGraph.setSize(graph_right_side, graph_bottom);
24 revisionGraph.setSize(graph_right_side, graph_bottom);
25
25
26 // init colors
26 // init colors
27 var colors = [];
27 var colors = [];
28 Raphael.getColor.reset();
28 Raphael.getColor.reset();
29 for (var k = 0; k <= graph_space; k++) {
29 for (var k = 0; k <= graph_space; k++) {
30 colors.push(Raphael.getColor());
30 colors.push(Raphael.getColor());
31 }
31 }
32
32
33 var parent_commit;
33 var parent_commit;
34 var x, y, parent_x, parent_y;
34 var x, y, parent_x, parent_y;
35 var path, title;
35 var path, title;
36 var revision_dot_overlay;
36 var revision_dot_overlay;
37 $.each(commits, function(index, commit) {
37 $.each(commits, function(index, commit) {
38 if (!commit.hasOwnProperty("space"))
39 commit.space = 0;
40
38 y = commit_table_rows.eq(max_rdmid - commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
41 y = commit_table_rows.eq(max_rdmid - commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
39 x = graph_x_offset + XSTEP / 2 + XSTEP * commit.space;
42 x = graph_x_offset + XSTEP / 2 + XSTEP * commit.space;
40 revisionGraph.circle(x, y, 3)
43 revisionGraph.circle(x, y, 3)
41 .attr({
44 .attr({
42 fill: colors[commit.space],
45 fill: colors[commit.space],
43 stroke: 'none',
46 stroke: 'none',
44 }).toFront();
47 }).toFront();
45 // paths to parents
48 // paths to parents
46 $.each(commit.parent_scmids, function(index, parent_scmid) {
49 $.each(commit.parent_scmids, function(index, parent_scmid) {
47 parent_commit = commits_by_scmid[parent_scmid];
50 parent_commit = commits_by_scmid[parent_scmid];
48 if (parent_commit) {
51 if (parent_commit) {
52 if (!parent_commit.hasOwnProperty("space"))
53 parent_commit.space = 0;
54
49 parent_y = commit_table_rows.eq(max_rdmid - parent_commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
55 parent_y = commit_table_rows.eq(max_rdmid - parent_commit.rdmid).position().top - graph_y_offset + CIRCLE_INROW_OFFSET;
50 parent_x = graph_x_offset + XSTEP / 2 + XSTEP * parent_commit.space;
56 parent_x = graph_x_offset + XSTEP / 2 + XSTEP * parent_commit.space;
51 if (parent_commit.space == commit.space) {
57 if (parent_commit.space == commit.space) {
52 // vertical path
58 // vertical path
53 path = revisionGraph.path([
59 path = revisionGraph.path([
54 'M', x, y,
60 'M', x, y,
55 'V', parent_y]);
61 'V', parent_y]);
56 } else {
62 } else {
57 // path to a commit in a different branch (Bezier curve)
63 // path to a commit in a different branch (Bezier curve)
58 path = revisionGraph.path([
64 path = revisionGraph.path([
59 'M', x, y,
65 'M', x, y,
60 'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
66 'C', x, y, x, y + (parent_y - y) / 2, x + (parent_x - x) / 2, y + (parent_y - y) / 2,
61 'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
67 'C', x + (parent_x - x) / 2, y + (parent_y - y) / 2, parent_x, parent_y-(parent_y-y)/2, parent_x, parent_y]);
62 }
68 }
63 } else {
69 } else {
64 // vertical path ending at the bottom of the revisionGraph
70 // vertical path ending at the bottom of the revisionGraph
65 path = revisionGraph.path([
71 path = revisionGraph.path([
66 'M', x, y,
72 'M', x, y,
67 'V', graph_bottom]);
73 'V', graph_bottom]);
68 }
74 }
69 path.attr({stroke: colors[commit.space], "stroke-width": 1.5}).toBack();
75 path.attr({stroke: colors[commit.space], "stroke-width": 1.5}).toBack();
70 });
76 });
71 revision_dot_overlay = revisionGraph.circle(x, y, 10);
77 revision_dot_overlay = revisionGraph.circle(x, y, 10);
72 revision_dot_overlay
78 revision_dot_overlay
73 .attr({
79 .attr({
74 fill: '#000',
80 fill: '#000',
75 opacity: 0,
81 opacity: 0,
76 cursor: 'pointer',
82 cursor: 'pointer',
77 href: commit.href
83 href: commit.href
78 });
84 });
79
85
80 if(commit.refs != null && commit.refs.length > 0) {
86 if(commit.refs != null && commit.refs.length > 0) {
81 title = document.createElementNS(revisionGraph.canvas.namespaceURI, 'title');
87 title = document.createElementNS(revisionGraph.canvas.namespaceURI, 'title');
82 title.appendChild(document.createTextNode(commit.refs));
88 title.appendChild(document.createTextNode(commit.refs));
83 revision_dot_overlay.node.appendChild(title);
89 revision_dot_overlay.node.appendChild(title);
84 }
90 }
85 top.push(revision_dot_overlay);
91 top.push(revision_dot_overlay);
86 });
92 });
87 top.toFront();
93 top.toFront();
88 };
94 };
General Comments 0
You need to be logged in to leave comments. Login now