@@ -271,7 +271,6 module RepositoriesHelper | |||||
271 | commits_by_scmid[commit.scmid] = { |
|
271 | commits_by_scmid[commit.scmid] = { | |
272 | :parent_scmids => commit.parents.collect { |parent| parent.scmid }, |
|
272 | :parent_scmids => commit.parents.collect { |parent| parent.scmid }, | |
273 | :rdmid => commit_index, |
|
273 | :rdmid => commit_index, | |
274 | :space => 0, |
|
|||
275 | :refs => refs_map.include?(commit.scmid) ? refs_map[commit.scmid].join(" ") : nil, |
|
274 | :refs => refs_map.include?(commit.scmid) ? refs_map[commit.scmid].join(" ") : nil, | |
276 | :scmid => commit.scmid, |
|
275 | :scmid => commit.scmid, | |
277 | :href => block_given? ? yield(commit.scmid) : commit.scmid |
|
276 | :href => block_given? ? yield(commit.scmid) : commit.scmid | |
@@ -280,40 +279,40 module RepositoriesHelper | |||||
280 |
|
279 | |||
281 | heads.sort! { |head1, head2| head1.to_s <=> head2.to_s } |
|
280 | heads.sort! { |head1, head2| head1.to_s <=> head2.to_s } | |
282 |
|
281 | |||
283 | mark_index = 0 |
|
282 | space = nil | |
284 | heads.each do |head| |
|
283 | heads.each do |head| | |
285 | if commits_by_scmid.include? head.scmid |
|
284 | if commits_by_scmid.include? head.scmid | |
286 | mark_index = mark_chain(mark_index += 1, commits_by_scmid[head.scmid], commits_by_scmid) |
|
285 | space = index_head((space || -1) + 1, head, commits_by_scmid) | |
287 | end |
|
286 | end | |
288 | end |
|
287 | end | |
|
288 | ||||
289 | # when no head matched anything use first commit |
|
289 | # when no head matched anything use first commit | |
290 | if mark_index == 0 |
|
290 | space ||= index_head(0, commits.first, commits_by_scmid) | |
291 | mark_chain(mark_index += 1, commits_by_scmid.values.first, commits_by_scmid) |
|
291 | ||
292 | end |
|
292 | return commits_by_scmid, space | |
293 | commits_by_scmid |
|
|||
294 | end |
|
293 | end | |
295 |
|
294 | |||
296 |
def |
|
295 | def index_head(space, commit, commits_by_scmid) | |
297 |
|
296 | |||
298 | stack = [[mark_index, commit]] |
|
297 | stack = [[space, commits_by_scmid[commit.scmid]]] | |
299 | mark_max_index = mark_index |
|
298 | max_space = space | |
300 |
|
299 | |||
301 | until stack.empty? |
|
300 | until stack.empty? | |
302 |
|
|
301 | space, commit = stack.pop | |
303 |
commit[:space] = |
|
302 | commit[:space] = space if commit[:space].nil? | |
304 |
|
303 | |||
305 |
|
|
304 | space -= 1 | |
306 | commit[:parent_scmids].each_with_index do |parent_scmid, parent_index| |
|
305 | commit[:parent_scmids].each_with_index do |parent_scmid, parent_index| | |
307 |
|
306 | |||
308 | parent_commit = commits_by_scmid[parent_scmid] |
|
307 | parent_commit = commits_by_scmid[parent_scmid] | |
309 |
|
308 | |||
310 |
if parent_commit and parent_commit[:space] |
|
309 | if parent_commit and parent_commit[:space].nil? | |
311 |
|
310 | |||
312 |
stack.unshift [ |
|
311 | stack.unshift [space += 1, parent_commit] | |
313 | end |
|
312 | end | |
314 | end |
|
313 | end | |
315 | mark_max_index = mark_index if mark_max_index < mark_index |
|
314 | max_space = space if max_space < space | |
316 | end |
|
315 | end | |
317 | mark_max_index |
|
316 | max_space | |
318 | end |
|
317 | end | |
319 | end |
|
318 | end |
@@ -4,9 +4,10 | |||||
4 | <script type="text/javascript" charset="utf-8"> |
|
4 | <script type="text/javascript" charset="utf-8"> | |
5 | Event.observe(window, 'load', function(){ |
|
5 | Event.observe(window, 'load', function(){ | |
6 | revisionGraph( |
|
6 | revisionGraph( | |
7 |
document.getElementById( |
|
7 | document.getElementById('holder'), | |
8 |
<%= commits.to_json.html_safe %> |
|
8 | <%= commits.to_json.html_safe %>, | |
|
9 | <%= space %>); | |||
9 | }); |
|
10 | }); | |
10 | </script> |
|
11 | </script> | |
11 |
|
12 | |||
12 | <div id="holder" class="graph"></div> |
|
13 | <div id="holder" class="revision-graph" style="width: <%= (space + 1) * 20 %>px;"></div> |
@@ -6,9 +6,6 | |||||
6 | ) do %> |
|
6 | ) do %> | |
7 | <table class="list changesets"> |
|
7 | <table class="list changesets"> | |
8 | <thead><tr> |
|
8 | <thead><tr> | |
9 | <% if show_revision_graph %> |
|
|||
10 | <th></th> |
|
|||
11 | <% end %> |
|
|||
12 | <th>#</th> |
|
9 | <th>#</th> | |
13 | <th></th> |
|
10 | <th></th> | |
14 | <th></th> |
|
11 | <th></th> | |
@@ -18,40 +15,30 | |||||
18 | </tr></thead> |
|
15 | </tr></thead> | |
19 | <tbody> |
|
16 | <tbody> | |
20 | <% show_diff = revisions.size > 1 %> |
|
17 | <% show_diff = revisions.size > 1 %> | |
|
18 | <%= if show_revision_graph && revisions && revisions.any? | |||
|
19 | indexed_commits, graph_space = index_commits(revisions, @repository.branches) do |scmid| | |||
|
20 | url_for( | |||
|
21 | :controller => 'repositories', | |||
|
22 | :action => 'revision', | |||
|
23 | :id => project, | |||
|
24 | :repository_id => @repository.identifier_param, | |||
|
25 | :rev => scmid) | |||
|
26 | end | |||
|
27 | render :partial => 'revision_graph', | |||
|
28 | :locals => { | |||
|
29 | :commits => indexed_commits, | |||
|
30 | :space => graph_space | |||
|
31 | } | |||
|
32 | end %> | |||
21 | <% line_num = 1 %> |
|
33 | <% line_num = 1 %> | |
22 | <% revisions.each do |changeset| %> |
|
34 | <% revisions.each do |changeset| %> | |
23 | <tr class="changeset <%= cycle 'odd', 'even' %>"> |
|
35 | <tr class="changeset <%= cycle 'odd', 'even' %>"> | |
24 | <% if show_revision_graph %> |
|
36 | <td class="id"<%= show_revision_graph ? " style=\"padding-left:#{(graph_space + 1) * 20}px\"" : '' %>><%= link_to_revision(changeset, @repository) %></td> | |
25 | <% if line_num == 1 %> |
|
|||
26 | <td class="revision_graph" rowspan="<%= revisions.size %>"> |
|
|||
27 | <%= render :partial => 'revision_graph', |
|
|||
28 | :locals => { |
|
|||
29 | :commits => index_commits( |
|
|||
30 | revisions, |
|
|||
31 | @repository.branches) do |scmid| |
|
|||
32 | url_for( |
|
|||
33 | :controller => 'repositories', |
|
|||
34 | :action => 'revision', |
|
|||
35 | :id => project, |
|
|||
36 | :repository_id => @repository.identifier_param, |
|
|||
37 | :rev => scmid) |
|
|||
38 | end |
|
|||
39 | } %> |
|
|||
40 | </td> |
|
|||
41 | <% end %> |
|
|||
42 | <% end %> |
|
|||
43 | <td class="id"><%= link_to_revision(changeset, @repository) %></td> |
|
|||
44 | <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> |
|
37 | <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> | |
45 | <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> |
|
38 | <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> | |
46 | <td class="committed_on"><%= format_time(changeset.committed_on) %></td> |
|
39 | <td class="committed_on"><%= format_time(changeset.committed_on) %></td> | |
47 | <td class="author"><%= h truncate(changeset.author.to_s, :length => 30) %></td> |
|
40 | <td class="author"><%= h truncate(changeset.author.to_s, :length => 30) %></td> | |
48 | <% if show_revision_graph %> |
|
41 | <td class="comments"><%= textilizable(truncate_at_line_break(changeset.comments)) %></td> | |
49 | <td class="comments_nowrap"> |
|
|||
50 | <%= textilizable(truncate(truncate_at_line_break(changeset.comments, 0), :length => 90)) %> |
|
|||
51 | </td> |
|
|||
52 | <% else %> |
|
|||
53 | <td class="comments"><%= textilizable(truncate_at_line_break(changeset.comments)) %></td> |
|
|||
54 | <% end %> |
|
|||
55 | </tr> |
|
42 | </tr> | |
56 | <% line_num += 1 %> |
|
43 | <% line_num += 1 %> | |
57 | <% end %> |
|
44 | <% end %> |
@@ -1,29 +1,25 | |||||
1 |
|
1 | |||
2 | function revisionGraph(holder, commits_hash) { |
|
2 | function revisionGraph(holder, commits_hash, graph_space) { | |
3 |
|
3 | |||
4 |
var |
|
4 | var XSTEP = 20, | |
5 | TOP_PADDING = 10, |
|
5 | CIRCLE_INROW_OFFSET = 10; | |
6 | XSTEP = 20; |
|
|||
7 |
|
||||
8 | var YSTEP = $$('tr.changeset')[0].getHeight(); |
|
|||
9 |
|
6 | |||
10 | var commits_by_scmid = $H(commits_hash), |
|
7 | var commits_by_scmid = $H(commits_hash), | |
11 | commits = commits_by_scmid.values(); |
|
8 | commits = commits_by_scmid.values(); | |
12 |
|
9 | |||
13 | // init max dimensions |
|
10 | var max_rdmid = commits.length - 1; | |
14 | var max_rdmid = max_space = 0; |
|
|||
15 | commits.each(function(commit) { |
|
|||
16 |
|
11 | |||
17 | max_rdmid = Math.max(max_rdmid, commit.rdmid); |
|
12 | var commit_table_rows = $$('table.changesets tr.changeset'); | |
18 | max_space = Math.max(max_space, commit.space); |
|
13 | ||
19 | }); |
|
14 | // init dimensions | |
|
15 | var graph_offset = $(holder).getLayout().get('top'), | |||
|
16 | graph_width = (graph_space + 1) * XSTEP, | |||
|
17 | graph_height = commit_table_rows[max_rdmid].getLayout().get('top') + commit_table_rows[max_rdmid].getLayout().get('height') - graph_offset; | |||
20 |
|
18 | |||
21 | var graph_height = max_rdmid * YSTEP + YSTEP, |
|
|||
22 | graph_width = max_space * XSTEP + XSTEP; |
|
|||
23 |
|
19 | |||
24 | // init colors |
|
20 | // init colors | |
25 |
var colors = [ |
|
21 | var colors = []; | |
26 |
for (var k = 0; k < |
|
22 | for (var k = 0; k < graph_space + 1; k++) { | |
27 | colors.push(Raphael.getColor()); |
|
23 | colors.push(Raphael.getColor()); | |
28 | } |
|
24 | } | |
29 |
|
25 | |||
@@ -37,8 +33,8 function revisionGraph(holder, commits_hash) { | |||||
37 |
|
33 | |||
38 | commits.each(function(commit) { |
|
34 | commits.each(function(commit) { | |
39 |
|
35 | |||
40 | y = TOP_PADDING + YSTEP *(max_rdmid - commit.rdmid); |
|
36 | y = commit_table_rows[max_rdmid - commit.rdmid].getLayout().get('top') - graph_offset + CIRCLE_INROW_OFFSET; | |
41 |
x = |
|
37 | x = XSTEP / 2 + XSTEP * commit.space; | |
42 |
|
38 | |||
43 | graph.circle(x, y, 3).attr({fill: colors[commit.space], stroke: 'none'}); |
|
39 | graph.circle(x, y, 3).attr({fill: colors[commit.space], stroke: 'none'}); | |
44 |
|
40 | |||
@@ -64,8 +60,8 function revisionGraph(holder, commits_hash) { | |||||
64 | parent_commit = commits_by_scmid.get(parent_scmid); |
|
60 | parent_commit = commits_by_scmid.get(parent_scmid); | |
65 |
|
61 | |||
66 | if (parent_commit) { |
|
62 | if (parent_commit) { | |
67 | parent_y = TOP_PADDING + YSTEP * (max_rdmid - parent_commit.rdmid); |
|
63 | parent_y = commit_table_rows[max_rdmid - parent_commit.rdmid].getLayout().get('top') - graph_offset + CIRCLE_INROW_OFFSET; | |
68 |
parent_x = |
|
64 | parent_x = XSTEP / 2 + XSTEP * parent_commit.space; | |
69 |
|
65 | |||
70 | if (parent_commit.space == commit.space) { |
|
66 | if (parent_commit.space == commit.space) { | |
71 | // vertical path |
|
67 | // vertical path |
@@ -176,7 +176,6 tr.changeset ul, ol { margin-top: 0px; margin-bottom: 0px; } | |||||
176 | tr.changeset td.revision_graph { width: 15%; background-color: #fffffb; } |
|
176 | tr.changeset td.revision_graph { width: 15%; background-color: #fffffb; } | |
177 | tr.changeset td.author { text-align: center; width: 15%; white-space:nowrap;} |
|
177 | tr.changeset td.author { text-align: center; width: 15%; white-space:nowrap;} | |
178 | tr.changeset td.committed_on { text-align: center; width: 15%; white-space:nowrap;} |
|
178 | tr.changeset td.committed_on { text-align: center; width: 15%; white-space:nowrap;} | |
179 | tr.changeset td.comments_nowrap { width: 45%; white-space:nowrap;} |
|
|||
180 |
|
179 | |||
181 | table.files tr.file td { text-align: center; } |
|
180 | table.files tr.file td { text-align: center; } | |
182 | table.files tr.file td.filename { text-align: left; padding-left: 24px; } |
|
181 | table.files tr.file td.filename { text-align: left; padding-left: 24px; } |
@@ -4,6 +4,8 table.revision-info td { | |||||
4 | padding: 0px; |
|
4 | padding: 0px; | |
5 | } |
|
5 | } | |
6 |
|
6 | |||
|
7 | div.revision-graph { position: absolute; overflow:hidden; } | |||
|
8 | ||||
7 | div.changeset-changes ul { margin: 0; padding: 0; } |
|
9 | div.changeset-changes ul { margin: 0; padding: 0; } | |
8 | div.changeset-changes ul > ul { margin-left: 18px; padding: 0; } |
|
10 | div.changeset-changes ul > ul { margin-left: 18px; padding: 0; } | |
9 |
|
11 |
General Comments 0
You need to be logged in to leave comments.
Login now