##// END OF EJS Templates
remove redundant empty lines from RepositoriesHelper...
Toshi MARUYAMA -
r10199:5441f8de4df5
parent child
Show More
@@ -252,16 +252,13 module RepositoriesHelper
252
252
253 def index_commits(commits, heads)
253 def index_commits(commits, heads)
254 return nil if commits.nil? or commits.first.parents.nil?
254 return nil if commits.nil? or commits.first.parents.nil?
255
256 refs_map = {}
255 refs_map = {}
257 heads.each do |head|
256 heads.each do |head|
258 refs_map[head.scmid] ||= []
257 refs_map[head.scmid] ||= []
259 refs_map[head.scmid] << head
258 refs_map[head.scmid] << head
260 end
259 end
261
262 commits_by_scmid = {}
260 commits_by_scmid = {}
263 commits.reverse.each_with_index do |commit, commit_index|
261 commits.reverse.each_with_index do |commit, commit_index|
264
265 commits_by_scmid[commit.scmid] = {
262 commits_by_scmid[commit.scmid] = {
266 :parent_scmids => commit.parents.collect { |parent| parent.scmid },
263 :parent_scmids => commit.parents.collect { |parent| parent.scmid },
267 :rdmid => commit_index,
264 :rdmid => commit_index,
@@ -270,38 +267,28 module RepositoriesHelper
270 :href => block_given? ? yield(commit.scmid) : commit.scmid
267 :href => block_given? ? yield(commit.scmid) : commit.scmid
271 }
268 }
272 end
269 end
273
274 heads.sort! { |head1, head2| head1.to_s <=> head2.to_s }
270 heads.sort! { |head1, head2| head1.to_s <=> head2.to_s }
275
276 space = nil
271 space = nil
277 heads.each do |head|
272 heads.each do |head|
278 if commits_by_scmid.include? head.scmid
273 if commits_by_scmid.include? head.scmid
279 space = index_head((space || -1) + 1, head, commits_by_scmid)
274 space = index_head((space || -1) + 1, head, commits_by_scmid)
280 end
275 end
281 end
276 end
282
283 # when no head matched anything use first commit
277 # when no head matched anything use first commit
284 space ||= index_head(0, commits.first, commits_by_scmid)
278 space ||= index_head(0, commits.first, commits_by_scmid)
285
286 return commits_by_scmid, space
279 return commits_by_scmid, space
287 end
280 end
288
281
289 def index_head(space, commit, commits_by_scmid)
282 def index_head(space, commit, commits_by_scmid)
290
291 stack = [[space, commits_by_scmid[commit.scmid]]]
283 stack = [[space, commits_by_scmid[commit.scmid]]]
292 max_space = space
284 max_space = space
293
294 until stack.empty?
285 until stack.empty?
295 space, commit = stack.pop
286 space, commit = stack.pop
296 commit[:space] = space if commit[:space].nil?
287 commit[:space] = space if commit[:space].nil?
297
298 space -= 1
288 space -= 1
299 commit[:parent_scmids].each_with_index do |parent_scmid, parent_index|
289 commit[:parent_scmids].each_with_index do |parent_scmid, parent_index|
300
301 parent_commit = commits_by_scmid[parent_scmid]
290 parent_commit = commits_by_scmid[parent_scmid]
302
303 if parent_commit and parent_commit[:space].nil?
291 if parent_commit and parent_commit[:space].nil?
304
305 stack.unshift [space += 1, parent_commit]
292 stack.unshift [space += 1, parent_commit]
306 end
293 end
307 end
294 end
General Comments 0
You need to be logged in to leave comments. Login now