remove redundant empty lines from RepositoriesHelper
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10382 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e659aff468
commit
5441f8de4d
@ -252,16 +252,13 @@ module RepositoriesHelper
|
|||||||
|
|
||||||
def index_commits(commits, heads)
|
def index_commits(commits, heads)
|
||||||
return nil if commits.nil? or commits.first.parents.nil?
|
return nil if commits.nil? or commits.first.parents.nil?
|
||||||
|
|
||||||
refs_map = {}
|
refs_map = {}
|
||||||
heads.each do |head|
|
heads.each do |head|
|
||||||
refs_map[head.scmid] ||= []
|
refs_map[head.scmid] ||= []
|
||||||
refs_map[head.scmid] << head
|
refs_map[head.scmid] << head
|
||||||
end
|
end
|
||||||
|
|
||||||
commits_by_scmid = {}
|
commits_by_scmid = {}
|
||||||
commits.reverse.each_with_index do |commit, commit_index|
|
commits.reverse.each_with_index do |commit, commit_index|
|
||||||
|
|
||||||
commits_by_scmid[commit.scmid] = {
|
commits_by_scmid[commit.scmid] = {
|
||||||
:parent_scmids => commit.parents.collect { |parent| parent.scmid },
|
:parent_scmids => commit.parents.collect { |parent| parent.scmid },
|
||||||
:rdmid => commit_index,
|
:rdmid => commit_index,
|
||||||
@ -270,38 +267,28 @@ module RepositoriesHelper
|
|||||||
:href => block_given? ? yield(commit.scmid) : commit.scmid
|
:href => block_given? ? yield(commit.scmid) : commit.scmid
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
heads.sort! { |head1, head2| head1.to_s <=> head2.to_s }
|
heads.sort! { |head1, head2| head1.to_s <=> head2.to_s }
|
||||||
|
|
||||||
space = nil
|
space = nil
|
||||||
heads.each do |head|
|
heads.each do |head|
|
||||||
if commits_by_scmid.include? head.scmid
|
if commits_by_scmid.include? head.scmid
|
||||||
space = index_head((space || -1) + 1, head, commits_by_scmid)
|
space = index_head((space || -1) + 1, head, commits_by_scmid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# when no head matched anything use first commit
|
# when no head matched anything use first commit
|
||||||
space ||= index_head(0, commits.first, commits_by_scmid)
|
space ||= index_head(0, commits.first, commits_by_scmid)
|
||||||
|
|
||||||
return commits_by_scmid, space
|
return commits_by_scmid, space
|
||||||
end
|
end
|
||||||
|
|
||||||
def index_head(space, commit, commits_by_scmid)
|
def index_head(space, commit, commits_by_scmid)
|
||||||
|
|
||||||
stack = [[space, commits_by_scmid[commit.scmid]]]
|
stack = [[space, commits_by_scmid[commit.scmid]]]
|
||||||
max_space = space
|
max_space = space
|
||||||
|
|
||||||
until stack.empty?
|
until stack.empty?
|
||||||
space, commit = stack.pop
|
space, commit = stack.pop
|
||||||
commit[:space] = space if commit[:space].nil?
|
commit[:space] = space if commit[:space].nil?
|
||||||
|
|
||||||
space -= 1
|
space -= 1
|
||||||
commit[:parent_scmids].each_with_index do |parent_scmid, parent_index|
|
commit[:parent_scmids].each_with_index do |parent_scmid, parent_index|
|
||||||
|
|
||||||
parent_commit = commits_by_scmid[parent_scmid]
|
parent_commit = commits_by_scmid[parent_scmid]
|
||||||
|
|
||||||
if parent_commit and parent_commit[:space].nil?
|
if parent_commit and parent_commit[:space].nil?
|
||||||
|
|
||||||
stack.unshift [space += 1, parent_commit]
|
stack.unshift [space += 1, parent_commit]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user