@@ -0,0 +1,13 | |||
|
1 | <%= javascript_include_tag "raphael.js" %> | |
|
2 | <script type="text/javascript" charset="utf-8"> | |
|
3 | var chunk = {commits:<%= commits.values.to_json %>} | |
|
4 | </script> | |
|
5 | <%= javascript_include_tag "revision_graph.js" %> | |
|
6 | ||
|
7 | <script type="text/javascript"> | |
|
8 | window.onload = function(){ | |
|
9 | branchGraph(document.getElementById("holder")); | |
|
10 | } | |
|
11 | </script> | |
|
12 | ||
|
13 | <div id="holder" class="graph"></div> |
@@ -0,0 +1,172 | |||
|
1 | var commits = chunk.commits, | |
|
2 | comms = {}, | |
|
3 | pixelsX = [], | |
|
4 | pixelsY = [], | |
|
5 | mmax = Math.max, | |
|
6 | max_rdmid = 0, | |
|
7 | max_space = 0, | |
|
8 | parents = {}; | |
|
9 | for (var i = 0, ii = commits.length; i < ii; i++) { | |
|
10 | for (var j = 0, jj = commits[i].parents.length; j < jj; j++) { | |
|
11 | parents[commits[i].parents[j][0]] = true; | |
|
12 | } | |
|
13 | max_rdmid = Math.max(max_rdmid, commits[i].rdmid); | |
|
14 | max_space = Math.max(max_space, commits[i].space); | |
|
15 | } | |
|
16 | ||
|
17 | for (i = 0; i < ii; i++) { | |
|
18 | if (commits[i].scmid in parents) { | |
|
19 | commits[i].isParent = true; | |
|
20 | } | |
|
21 | comms[commits[i].scmid] = commits[i]; | |
|
22 | } | |
|
23 | var colors = ["#000"]; | |
|
24 | for (var k = 0; k < max_space; k++) { | |
|
25 | colors.push(Raphael.getColor()); | |
|
26 | } | |
|
27 | ||
|
28 | function branchGraph(holder) { | |
|
29 | var xstep = 20, ystep = 20; | |
|
30 | var ch, cw; | |
|
31 | cw = max_space * xstep + xstep; | |
|
32 | ch = max_rdmid * ystep + ystep; | |
|
33 | var r = Raphael("holder", cw, ch), | |
|
34 | top = r.set(); | |
|
35 | var cuday = 0, cumonth = ""; | |
|
36 | ||
|
37 | for (i = 0; i < ii; i++) { | |
|
38 | var x, y; | |
|
39 | y = 10 + ystep *(max_rdmid - commits[i].rdmid); | |
|
40 | x = 3 + xstep * commits[i].space; | |
|
41 | var stroke = "none"; | |
|
42 | r.circle(x, y, 3).attr({fill: colors[commits[i].space], stroke: stroke}); | |
|
43 | if (commits[i].refs != null && commits[i].refs != "") { | |
|
44 | var longrefs = commits[i].refs | |
|
45 | var shortrefs = commits[i].refs; | |
|
46 | if (shortrefs.length > 15) { | |
|
47 | shortrefs = shortrefs.substr(0,13) + "..."; | |
|
48 | } | |
|
49 | var t = r.text(x+5,y+5,shortrefs).attr({font: "12px Fontin-Sans, Arial", fill: "#666", | |
|
50 | title: longrefs, cursor: "pointer", rotation: "0"}); | |
|
51 | ||
|
52 | var textbox = t.getBBox(); | |
|
53 | t.translate(textbox.width / 2, textbox.height / -3); | |
|
54 | } | |
|
55 | for (var j = 0, jj = commits[i].parents.length; j < jj; j++) { | |
|
56 | var c = comms[commits[i].parents[j][0]]; | |
|
57 | var p,arrow; | |
|
58 | if (c) { | |
|
59 | var cy, cx; | |
|
60 | cy = 10 + ystep * (max_rdmid - c.rdmid), | |
|
61 | cx = 3 + xstep * c.space; | |
|
62 | ||
|
63 | if (c.space == commits[i].space) { | |
|
64 | p = r.path("M" + x + "," + y + "L" + cx + "," + cy); | |
|
65 | } else { | |
|
66 | p = r.path(["M", x, y, "C",x,y,x, y+(cy-y)/2,x+(cx-x)/2, y+(cy-y)/2, | |
|
67 | "C", x+(cx-x)/2,y+(cy-y)/2, cx, cy-(cy-y)/2, cx, cy]); | |
|
68 | } | |
|
69 | } else { | |
|
70 | p = r.path("M" + x + "," + y + "L" + x + "," + ch); | |
|
71 | } | |
|
72 | p.attr({stroke: colors[commits[i].space], "stroke-width": 1.5}); | |
|
73 | } | |
|
74 | (function (c, x, y) { | |
|
75 | top.push(r.circle(x, y, 10).attr({fill: "#000", opacity: 0, | |
|
76 | cursor: "pointer", href: commits[i].href}) | |
|
77 | .hover(function () {}, function () {}) | |
|
78 | ); | |
|
79 | }(commits[i], x, y)); | |
|
80 | } | |
|
81 | top.toFront(); | |
|
82 | var hw = holder.offsetWidth, | |
|
83 | hh = holder.offsetHeight, | |
|
84 | drag, | |
|
85 | dragger = function (e) { | |
|
86 | if (drag) { | |
|
87 | e = e || window.event; | |
|
88 | holder.scrollLeft = drag.sl - (e.clientX - drag.x); | |
|
89 | holder.scrollTop = drag.st - (e.clientY - drag.y); | |
|
90 | } | |
|
91 | }; | |
|
92 | holder.onmousedown = function (e) { | |
|
93 | e = e || window.event; | |
|
94 | drag = {x: e.clientX, y: e.clientY, st: holder.scrollTop, sl: holder.scrollLeft}; | |
|
95 | document.onmousemove = dragger; | |
|
96 | }; | |
|
97 | document.onmouseup = function () { | |
|
98 | drag = false; | |
|
99 | document.onmousemove = null; | |
|
100 | }; | |
|
101 | holder.scrollLeft = cw; | |
|
102 | }; | |
|
103 | ||
|
104 | Raphael.fn.popupit = function (x, y, set, dir, size) { | |
|
105 | dir = dir == null ? 2 : dir; | |
|
106 | size = size || 5; | |
|
107 | x = Math.round(x); | |
|
108 | y = Math.round(y); | |
|
109 | var bb = set.getBBox(), | |
|
110 | w = Math.round(bb.width / 2), | |
|
111 | h = Math.round(bb.height / 2), | |
|
112 | dx = [0, w + size * 2, 0, -w - size * 2], | |
|
113 | dy = [-h * 2 - size * 3, -h - size, 0, -h - size], | |
|
114 | p = ["M", x - dx[dir], y - dy[dir], "l", -size, (dir == 2) * -size, -mmax(w - size, 0), | |
|
115 | 0, "a", size, size, 0, 0, 1, -size, -size, | |
|
116 | "l", 0, -mmax(h - size, 0), (dir == 3) * -size, -size, (dir == 3) * size, -size, 0, | |
|
117 | -mmax(h - size, 0), "a", size, size, 0, 0, 1, size, -size, | |
|
118 | "l", mmax(w - size, 0), 0, size, !dir * -size, size, !dir * size, mmax(w - size, 0), | |
|
119 | 0, "a", size, size, 0, 0, 1, size, size, | |
|
120 | "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, | |
|
121 | mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size, | |
|
122 | "l", -mmax(w - size, 0), 0, "z"].join(","), | |
|
123 | xy = [{x: x, y: y + size * 2 + h}, | |
|
124 | {x: x - size * 2 - w, y: y}, | |
|
125 | {x: x, y: y - size * 2 - h}, | |
|
126 | {x: x + size * 2 + w, y: y}] | |
|
127 | [dir]; | |
|
128 | set.translate(xy.x - w - bb.x, xy.y - h - bb.y); | |
|
129 | return this.set(this.path(p).attr({fill: "#234", stroke: "none"}) | |
|
130 | .insertBefore(set.node ? set : set[0]), set); | |
|
131 | }; | |
|
132 | ||
|
133 | Raphael.fn.popup = function (x, y, text, dir, size) { | |
|
134 | dir = dir == null ? 2 : dir > 3 ? 3 : dir; | |
|
135 | size = size || 5; | |
|
136 | text = text || "$9.99"; | |
|
137 | var res = this.set(), | |
|
138 | d = 3; | |
|
139 | res.push(this.path().attr({fill: "#000", stroke: "#000"})); | |
|
140 | res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff", "font-family": "Helvetica, Arial"})); | |
|
141 | res.update = function (X, Y, withAnimation) { | |
|
142 | X = X || x; | |
|
143 | Y = Y || y; | |
|
144 | var bb = this[1].getBBox(), | |
|
145 | w = bb.width / 2, | |
|
146 | h = bb.height / 2, | |
|
147 | dx = [0, w + size * 2, 0, -w - size * 2], | |
|
148 | dy = [-h * 2 - size * 3, -h - size, 0, -h - size], | |
|
149 | p = ["M", X - dx[dir], Y - dy[dir], "l", -size, (dir == 2) * -size, | |
|
150 | -mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, -size, -size, | |
|
151 | "l", 0, -mmax(h - size, 0), (dir == 3) * -size, -size, (dir == 3) * size, -size, | |
|
152 | 0, -mmax(h - size, 0), "a", size, size, 0, 0, 1, size, -size, | |
|
153 | "l", mmax(w - size, 0), 0, size, !dir * -size, size, !dir * size, mmax(w - size, 0), | |
|
154 | 0, "a", size, size, 0, 0, 1, size, size, | |
|
155 | "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, | |
|
156 | mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size, | |
|
157 | "l", -mmax(w - size, 0), 0, "z"].join(","), | |
|
158 | xy = [{x: X, y: Y + size * 2 + h}, | |
|
159 | {x: X - size * 2 - w, y: Y}, | |
|
160 | {x: X, y: Y - size * 2 - h}, | |
|
161 | {x: X + size * 2 + w, y: Y}] | |
|
162 | [dir]; | |
|
163 | xy.path = p; | |
|
164 | if (withAnimation) { | |
|
165 | this.animate(xy, 500, ">"); | |
|
166 | } else { | |
|
167 | this.attr(xy); | |
|
168 | } | |
|
169 | return this; | |
|
170 | }; | |
|
171 | return res.update(x, y); | |
|
172 | }; |
@@ -283,4 +283,60 module RepositoriesHelper | |||
|
283 | 283 | ) + |
|
284 | 284 | '<br />'.html_safe + l(:text_scm_path_encoding_note)) |
|
285 | 285 | end |
|
286 | ||
|
287 | def index_commits(commits, heads, href_proc = nil) | |
|
288 | return nil if commits.nil? or commits.first.parents.nil? | |
|
289 | map = {} | |
|
290 | commit_hashes = [] | |
|
291 | refs_map = {} | |
|
292 | href_proc ||= Proc.new {|x|x} | |
|
293 | heads.each{|r| refs_map[r.scmid] ||= []; refs_map[r.scmid] << r} | |
|
294 | commits.reverse.each_with_index do |c, i| | |
|
295 | h = {} | |
|
296 | h[:parents] = c.parents.collect do |p| | |
|
297 | [p.scmid, 0, 0] | |
|
298 | end | |
|
299 | h[:rdmid] = i | |
|
300 | h[:space] = 0 | |
|
301 | h[:refs] = refs_map[c.scmid].join(" ") if refs_map.include? c.scmid | |
|
302 | h[:scmid] = c.scmid | |
|
303 | h[:href] = href_proc.call(c.scmid) | |
|
304 | commit_hashes << h | |
|
305 | map[c.scmid] = h | |
|
306 | end | |
|
307 | heads.sort! do |a,b| | |
|
308 | a.to_s <=> b.to_s | |
|
309 | end | |
|
310 | j = 0 | |
|
311 | heads.each do |h| | |
|
312 | if map.include? h.scmid then | |
|
313 | j = mark_chain(j += 1, map[h.scmid], map) | |
|
314 | end | |
|
315 | end | |
|
316 | # when no head matched anything use first commit | |
|
317 | if j == 0 then | |
|
318 | mark_chain(j += 1, map.values.first, map) | |
|
319 | end | |
|
320 | map | |
|
321 | end | |
|
322 | ||
|
323 | def mark_chain(mark, commit, map) | |
|
324 | stack = [[mark, commit]] | |
|
325 | markmax = mark | |
|
326 | until stack.empty? | |
|
327 | current = stack.pop | |
|
328 | m, commit = current | |
|
329 | commit[:space] = m if commit[:space] == 0 | |
|
330 | m1 = m - 1 | |
|
331 | commit[:parents].each_with_index do |p, i| | |
|
332 | psha = p[0] | |
|
333 | if map.include? psha and map[psha][:space] == 0 then | |
|
334 | stack << [m1 += 1, map[psha]] if i == 0 | |
|
335 | stack = [[m1 += 1, map[psha]]] + stack if i > 0 | |
|
336 | end | |
|
337 | end | |
|
338 | markmax = m1 if markmax < m1 | |
|
339 | end | |
|
340 | markmax | |
|
341 | end | |
|
286 | 342 | end |
@@ -1,6 +1,9 | |||
|
1 | 1 | <% form_tag({:controller => 'repositories', :action => 'diff', :id => @project, :path => to_path_param(path)}, :method => :get) do %> |
|
2 | 2 | <table class="list changesets"> |
|
3 | 3 | <thead><tr> |
|
4 | <% if @repository.supports_revision_graph? %> | |
|
5 | <th></th> | |
|
6 | <% end %> | |
|
4 | 7 | <th>#</th> |
|
5 | 8 | <th></th> |
|
6 | 9 | <th></th> |
@@ -13,12 +16,36 | |||
|
13 | 16 | <% line_num = 1 %> |
|
14 | 17 | <% revisions.each do |changeset| %> |
|
15 | 18 | <tr class="changeset <%= cycle 'odd', 'even' %>"> |
|
19 | <% if @repository.supports_revision_graph? %> | |
|
20 | <% if line_num == 1 %> | |
|
21 | <td class="revision_graph" rowspan="<%= revisions.size %>"> | |
|
22 | <% href_base = Proc.new {|x| url_for(:controller => 'repositories', | |
|
23 | :action => 'revision', | |
|
24 | :id => project, | |
|
25 | :rev => x) } %> | |
|
26 | <%= render :partial => 'revision_graph', | |
|
27 | :locals => { | |
|
28 | :commits => index_commits( | |
|
29 | revisions, | |
|
30 | @repository.branches, | |
|
31 | href_base | |
|
32 | ) | |
|
33 | } %> | |
|
34 | </td> | |
|
35 | <% end %> | |
|
36 | <% end %> | |
|
16 | 37 | <td class="id"><%= link_to_revision(changeset, project) %></td> |
|
17 | 38 | <td class="checkbox"><%= radio_button_tag('rev', changeset.identifier, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('cbto-#{line_num+1}').checked=true;") if show_diff && (line_num < revisions.size) %></td> |
|
18 | 39 | <td class="checkbox"><%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('cb-#{line_num}').checked==true) {$('cb-#{line_num-1}').checked=true;}") if show_diff && (line_num > 1) %></td> |
|
19 | 40 | <td class="committed_on"><%= format_time(changeset.committed_on) %></td> |
|
20 | 41 | <td class="author"><%= h truncate(changeset.author.to_s, :length => 30) %></td> |
|
21 | <td class="comments"><%= textilizable(truncate_at_line_break(changeset.comments)) %></td> | |
|
42 | <% if @repository.supports_revision_graph? %> | |
|
43 | <td class="comments_nowrap"> | |
|
44 | <%= textilizable(truncate(truncate_at_line_break(changeset.comments, 0), :length => 90)) %> | |
|
45 | </td> | |
|
46 | <% else %> | |
|
47 | <td class="comments"><%= textilizable(truncate_at_line_break(changeset.comments)) %></td> | |
|
48 | <% end %> | |
|
22 | 49 | </tr> |
|
23 | 50 | <% line_num += 1 %> |
|
24 | 51 | <% end %> |
@@ -155,9 +155,12 tr.entry.file td.filename_no_report a { margin-left: 16px; } | |||
|
155 | 155 | tr span.expander {background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;} |
|
156 | 156 | tr.open span.expander {background-image: url(../images/bullet_toggle_minus.png);} |
|
157 | 157 | |
|
158 | tr.changeset { height: 20px } | |
|
158 | 159 | tr.changeset ul, ol { margin-top: 0px; margin-bottom: 0px; } |
|
160 | tr.changeset td.revision_graph { width: 15%; background-color: #fffffb; } | |
|
159 | 161 | tr.changeset td.author { text-align: center; width: 15%; white-space:nowrap;} |
|
160 | 162 | tr.changeset td.committed_on { text-align: center; width: 15%; white-space:nowrap;} |
|
163 | tr.changeset td.comments_nowrap { width: 45%; white-space:nowrap;} | |
|
161 | 164 | |
|
162 | 165 | table.files tr.file td { text-align: center; } |
|
163 | 166 | table.files tr.file td.filename { text-align: left; padding-left: 24px; } |
General Comments 0
You need to be logged in to leave comments.
Login now