diff options
author | Sato Hiroyuki <sathiroyuki@gmail.com> | 2013-03-20 09:17:12 +0000 |
---|---|---|
committer | Sato Hiroyuki <sathiroyuki@gmail.com> | 2013-03-20 12:28:22 +0000 |
commit | 1f6b6b6c629592e3ecc08e9dac6514a4b1a831a0 (patch) | |
tree | 29142abfaeb6f41f99020c758cc9ed269f88f291 /app/models/network | |
parent | 175e09f16742cbc8d5535e548cef880768ec3397 (diff) | |
download | gitlab-ce-1f6b6b6c629592e3ecc08e9dac6514a4b1a831a0.tar.gz |
Rotating graph orientation.
Diffstat (limited to 'app/models/network')
-rw-r--r-- | app/models/network/graph.rb | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb index 4b1abf5215e..2957adbfc19 100644 --- a/app/models/network/graph.rb +++ b/app/models/network/graph.rb @@ -40,15 +40,12 @@ module Network def index_commits days = [] @map = {} + @reserved = {} - @commits.reverse.each_with_index do |c,i| + @commits.each_with_index do |c,i| c.time = i days[i] = c.committed_date @map[c.id] = c - end - - @reserved = {} - days.each_index do |i| @reserved[i] = [] end @@ -135,11 +132,7 @@ module Network spaces = [] commit.parents(@map).each do |parent| - range = if commit.time < parent.time then - commit.time..parent.time - else - parent.time..commit.time - end + range = commit.time..parent.time space = if commit.space >= parent.space then find_free_parent_space(range, parent.space, -1, commit.space) @@ -166,7 +159,7 @@ module Network range.each do |i| if i != range.first && i != range.last && - @commits[reversed_index(i)].spaces.include?(overlap_space) then + @commits[i].spaces.include?(overlap_space) then return true; end @@ -184,7 +177,7 @@ module Network return end - time_range = leaves.last.time..leaves.first.time + time_range = leaves.first.time..leaves.last.time space_base = get_space_base(leaves) space = find_free_space(time_range, 2, space_base) leaves.each do |l| @@ -198,17 +191,17 @@ module Network end # and mark it as reserved - min_time = leaves.last.time - leaves.last.parents(@map).each do |parent| - if parent.time < min_time - min_time = parent.time - end - end - if parent_time.nil? - max_time = leaves.first.time + min_time = leaves.first.time else - max_time = parent_time - 1 + min_time = parent_time + 1 + end + + max_time = leaves.last.time + leaves.last.parents(@map).each do |parent| + if max_time < parent.time + max_time = parent.time + end end mark_reserved(min_time..max_time, space) @@ -289,9 +282,5 @@ module Network end refs_cache end - - def reversed_index(index) - -index - 1 - end end end |