Commit 56000aea227c2805759db42f536d31ba3c533aff
Exists in
master
and in
4 other branches
Merge pull request #2855 from hiroponz/fix-bug-of-network-graph
Fix bug of network graph(#2847) and trivial code clean up.
Showing
2 changed files
with
16 additions
and
9 deletions
Show diff stats
lib/gitlab/graph/json_builder.rb
@@ -109,9 +109,9 @@ module Gitlab | @@ -109,9 +109,9 @@ module Gitlab | ||
109 | end | 109 | end |
110 | 110 | ||
111 | space = if commit.space >= parent.space then | 111 | space = if commit.space >= parent.space then |
112 | - find_free_parent_space(range, map, parent.space, 1, commit.space, times) | 112 | + find_free_parent_space(range, parent.space, 1, commit.space, times) |
113 | else | 113 | else |
114 | - find_free_parent_space(range, map, parent.space, -1, parent.space, times) | 114 | + find_free_parent_space(range, parent.space, -1, parent.space, times) |
115 | end | 115 | end |
116 | 116 | ||
117 | mark_reserved(range, space) | 117 | mark_reserved(range, space) |
@@ -122,9 +122,9 @@ module Gitlab | @@ -122,9 +122,9 @@ module Gitlab | ||
122 | spaces | 122 | spaces |
123 | end | 123 | end |
124 | 124 | ||
125 | - def find_free_parent_space(range, map, space_base, space_step, space_default, times) | 125 | + def find_free_parent_space(range, space_base, space_step, space_default, times) |
126 | if is_overlap?(range, times, space_default) then | 126 | if is_overlap?(range, times, space_default) then |
127 | - find_free_space(range, map, space_base, space_step) | 127 | + find_free_space(range, space_base, space_step) |
128 | else | 128 | else |
129 | space_default | 129 | space_default |
130 | end | 130 | end |
@@ -152,11 +152,9 @@ module Gitlab | @@ -152,11 +152,9 @@ module Gitlab | ||
152 | if leaves.empty? | 152 | if leaves.empty? |
153 | return | 153 | return |
154 | end | 154 | end |
155 | - time_range = leaves.last.time..leaves.first.time | ||
156 | - space = find_free_space(time_range, map, 1, 2) | ||
157 | - leaves.each{|l| l.space = space} | ||
158 | # and mark it as reserved | 155 | # and mark it as reserved |
159 | min_time = leaves.last.time | 156 | min_time = leaves.last.time |
157 | + max_space = 1 | ||
160 | parents = leaves.last.parents.collect | 158 | parents = leaves.last.parents.collect |
161 | parents.each do |p| | 159 | parents.each do |p| |
162 | if map.include? p.id | 160 | if map.include? p.id |
@@ -164,6 +162,9 @@ module Gitlab | @@ -164,6 +162,9 @@ module Gitlab | ||
164 | if parent.time < min_time | 162 | if parent.time < min_time |
165 | min_time = parent.time | 163 | min_time = parent.time |
166 | end | 164 | end |
165 | + if max_space < parent.space then | ||
166 | + max_space = parent.space | ||
167 | + end | ||
167 | end | 168 | end |
168 | end | 169 | end |
169 | if parent_time.nil? | 170 | if parent_time.nil? |
@@ -171,6 +172,11 @@ module Gitlab | @@ -171,6 +172,11 @@ module Gitlab | ||
171 | else | 172 | else |
172 | max_time = parent_time - 1 | 173 | max_time = parent_time - 1 |
173 | end | 174 | end |
175 | + | ||
176 | + time_range = leaves.last.time..leaves.first.time | ||
177 | + space = find_free_space(time_range, max_space, 2) | ||
178 | + leaves.each{|l| l.space = space} | ||
179 | + | ||
174 | mark_reserved(min_time..max_time, space) | 180 | mark_reserved(min_time..max_time, space) |
175 | 181 | ||
176 | # Visit branching chains | 182 | # Visit branching chains |
@@ -188,11 +194,12 @@ module Gitlab | @@ -188,11 +194,12 @@ module Gitlab | ||
188 | end | 194 | end |
189 | end | 195 | end |
190 | 196 | ||
191 | - def find_free_space(time_range, map, space_base, space_step) | 197 | + def find_free_space(time_range, space_base, space_step) |
192 | reserved = [] | 198 | reserved = [] |
193 | for day in time_range | 199 | for day in time_range |
194 | reserved += @_reserved[day] | 200 | reserved += @_reserved[day] |
195 | end | 201 | end |
202 | + reserved.uniq! | ||
196 | 203 | ||
197 | space = space_base | 204 | space = space_base |
198 | while reserved.include?(space) do | 205 | while reserved.include?(space) do |
vendor/assets/javascripts/branch-graph.js
@@ -122,7 +122,7 @@ | @@ -122,7 +122,7 @@ | ||
122 | var cx = offsetX + 20 * c.time | 122 | var cx = offsetX + 20 * c.time |
123 | , cy = offsetY + 10 * c.space | 123 | , cy = offsetY + 10 * c.space |
124 | , psy = offsetY + 10 * ps; | 124 | , psy = offsetY + 10 * ps; |
125 | - if (c.space == this.commits[i].space) { | 125 | + if (c.space == this.commits[i].space && c.space == ps) { |
126 | r.path([ | 126 | r.path([ |
127 | "M", x, y, | 127 | "M", x, y, |
128 | "L", cx, cy | 128 | "L", cx, cy |