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