Merge pull request #2260 from hiroponz/improve-network-graph
Improve network-graph
This commit is contained in:
commit
a5d7a95893
|
@ -97,7 +97,7 @@ module Gitlab
|
|||
if leaves.empty?
|
||||
return
|
||||
end
|
||||
space = find_free_space(leaves.last.time..leaves.first.time)
|
||||
space = find_free_space(leaves, map)
|
||||
leaves.each{|l| l.space = space}
|
||||
# and mark it as reserved
|
||||
min_time = leaves.last.time
|
||||
|
@ -119,7 +119,7 @@ module Gitlab
|
|||
|
||||
# Visit branching chains
|
||||
leaves.each do |l|
|
||||
parents = l.parents.collect.select{|p| map.include? p.id and map[p.id].space == 0}
|
||||
parents = l.parents.collect.select{|p| map.include? p.id and map[p.id].space.zero?}
|
||||
for p in parents
|
||||
place_chain(map[p.id], map, l.time)
|
||||
end
|
||||
|
@ -132,18 +132,29 @@ module Gitlab
|
|||
end
|
||||
end
|
||||
|
||||
def find_free_space(time_range)
|
||||
def find_free_space(leaves, map)
|
||||
time_range = leaves.last.time..leaves.first.time
|
||||
reserved = []
|
||||
for day in time_range
|
||||
reserved += @_reserved[day]
|
||||
end
|
||||
space = 1
|
||||
space = base_space(leaves, map)
|
||||
while reserved.include? space do
|
||||
space += 1
|
||||
end
|
||||
space
|
||||
end
|
||||
|
||||
def base_space(leaves, map)
|
||||
parents = []
|
||||
leaves.each do |l|
|
||||
parents.concat l.parents.collect.select{|p| map.include? p.id and map[p.id].space.nonzero?}
|
||||
end
|
||||
|
||||
space = parents.map{|p| map[p.id].space}.max || 0
|
||||
space += 1
|
||||
end
|
||||
|
||||
# Takes most left subtree branch of commits
|
||||
# which don't have space mark yet.
|
||||
#
|
||||
|
@ -156,13 +167,13 @@ module Gitlab
|
|||
leaves.push(commit) if commit.space.zero?
|
||||
|
||||
while true
|
||||
parent = commit.parents.collect.select do |p|
|
||||
map.include? p.id and map[p.id].space == 0
|
||||
end
|
||||
return leaves if commit.parents.count.zero?
|
||||
return leaves unless map.include? commit.parents.first.id
|
||||
|
||||
return leaves if parent.count.zero?
|
||||
commit = map[commit.parents.first.id]
|
||||
|
||||
return leaves unless commit.space.zero?
|
||||
|
||||
commit = map[parent.first.id]
|
||||
leaves.push(commit)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue