summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSato Hiroyuki <sathiroyuki@gmail.com>2013-01-31 17:29:36 +0900
committerSato Hiroyuki <sathiroyuki@gmail.com>2013-01-31 17:48:51 +0900
commit41332212005d2a6d2d2131bc30c29bd29b81453e (patch)
treee8709c98cbd1c807257a7cfaeda035482d9913cf
parent9da7b2e8d8ed08cb193af2babf150cb8c7715f80 (diff)
downloadgitlab-ce-41332212005d2a6d2d2131bc30c29bd29b81453e.tar.gz
Fix bug of network graph(#2847) and trivial code clean up.
-rw-r--r--lib/gitlab/graph/json_builder.rb23
-rw-r--r--vendor/assets/javascripts/branch-graph.js2
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/gitlab/graph/json_builder.rb b/lib/gitlab/graph/json_builder.rb
index 90d384449f5..4b3687e06c3 100644
--- a/lib/gitlab/graph/json_builder.rb
+++ b/lib/gitlab/graph/json_builder.rb
@@ -109,9 +109,9 @@ module Gitlab
end
space = if commit.space >= parent.space then
- find_free_parent_space(range, map, parent.space, 1, commit.space, times)
+ find_free_parent_space(range, parent.space, 1, commit.space, times)
else
- find_free_parent_space(range, map, parent.space, -1, parent.space, times)
+ find_free_parent_space(range, parent.space, -1, parent.space, times)
end
mark_reserved(range, space)
@@ -122,9 +122,9 @@ module Gitlab
spaces
end
- def find_free_parent_space(range, map, space_base, space_step, space_default, times)
+ def find_free_parent_space(range, space_base, space_step, space_default, times)
if is_overlap?(range, times, space_default) then
- find_free_space(range, map, space_base, space_step)
+ find_free_space(range, space_base, space_step)
else
space_default
end
@@ -152,11 +152,9 @@ module Gitlab
if leaves.empty?
return
end
- time_range = leaves.last.time..leaves.first.time
- space = find_free_space(time_range, map, 1, 2)
- leaves.each{|l| l.space = space}
# and mark it as reserved
min_time = leaves.last.time
+ max_space = 1
parents = leaves.last.parents.collect
parents.each do |p|
if map.include? p.id
@@ -164,6 +162,9 @@ module Gitlab
if parent.time < min_time
min_time = parent.time
end
+ if max_space < parent.space then
+ max_space = parent.space
+ end
end
end
if parent_time.nil?
@@ -171,6 +172,11 @@ module Gitlab
else
max_time = parent_time - 1
end
+
+ time_range = leaves.last.time..leaves.first.time
+ space = find_free_space(time_range, max_space, 2)
+ leaves.each{|l| l.space = space}
+
mark_reserved(min_time..max_time, space)
# Visit branching chains
@@ -188,11 +194,12 @@ module Gitlab
end
end
- def find_free_space(time_range, map, space_base, space_step)
+ def find_free_space(time_range, space_base, space_step)
reserved = []
for day in time_range
reserved += @_reserved[day]
end
+ reserved.uniq!
space = space_base
while reserved.include?(space) do
diff --git a/vendor/assets/javascripts/branch-graph.js b/vendor/assets/javascripts/branch-graph.js
index 4ca8680416b..7929d3b2a14 100644
--- a/vendor/assets/javascripts/branch-graph.js
+++ b/vendor/assets/javascripts/branch-graph.js
@@ -122,7 +122,7 @@
var cx = offsetX + 20 * c.time
, cy = offsetY + 10 * c.space
, psy = offsetY + 10 * ps;
- if (c.space == this.commits[i].space) {
+ if (c.space == this.commits[i].space && c.space == ps) {
r.path([
"M", x, y,
"L", cx, cy