scm: git: fix model source indents (#10470)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9284 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2012-03-28 17:18:19 +00:00
parent 9b333e1c87
commit 5232d379f9

View File

@ -155,56 +155,56 @@ class Repository::Git < Repository
end end
def save_revisions(prev_db_heads, repo_heads) def save_revisions(prev_db_heads, repo_heads)
h = {} h = {}
opts = {} opts = {}
opts[:reverse] = true opts[:reverse] = true
opts[:excludes] = prev_db_heads opts[:excludes] = prev_db_heads
opts[:includes] = repo_heads opts[:includes] = repo_heads
revisions = scm.revisions('', nil, nil, opts) revisions = scm.revisions('', nil, nil, opts)
return if revisions.blank? return if revisions.blank?
# Make the search for existing revisions in the database in a more sufficient manner # Make the search for existing revisions in the database in a more sufficient manner
# This is replacing the one-after-one queries. # This is replacing the one-after-one queries.
# Find all revisions, that are in the database, and then remove them from the revision array. # Find all revisions, that are in the database, and then remove them from the revision array.
# Then later we won't need any conditions for db existence. # Then later we won't need any conditions for db existence.
# Query for several revisions at once, and remove them from the revisions array, if they are there. # Query for several revisions at once, and remove them from the revisions array, if they are there.
# Do this in chunks, to avoid eventual memory problems (in case of tens of thousands of commits). # Do this in chunks, to avoid eventual memory problems (in case of tens of thousands of commits).
# If there are no revisions (because the original code's algoritm filtered them), # If there are no revisions (because the original code's algoritm filtered them),
# then this part will be stepped over. # then this part will be stepped over.
# We make queries, just if there is any revision. # We make queries, just if there is any revision.
limit = 100 limit = 100
offset = 0 offset = 0
revisions_copy = revisions.clone # revisions will change revisions_copy = revisions.clone # revisions will change
while offset < revisions_copy.size while offset < revisions_copy.size
recent_changesets_slice = changesets.find( recent_changesets_slice = changesets.find(
:all, :all,
:conditions => [ :conditions => [
'scmid IN (?)', 'scmid IN (?)',
revisions_copy.slice(offset, limit).map{|x| x.scmid} revisions_copy.slice(offset, limit).map{|x| x.scmid}
] ]
) )
# Subtract revisions that redmine already knows about # Subtract revisions that redmine already knows about
recent_revisions = recent_changesets_slice.map{|c| c.scmid} recent_revisions = recent_changesets_slice.map{|c| c.scmid}
revisions.reject!{|r| recent_revisions.include?(r.scmid)} revisions.reject!{|r| recent_revisions.include?(r.scmid)}
offset += limit offset += limit
end end
revisions.each do |rev| revisions.each do |rev|
transaction do transaction do
# There is no search in the db for this revision, because above we ensured, # There is no search in the db for this revision, because above we ensured,
# that it's not in the db. # that it's not in the db.
db_saved_rev = save_revision(rev) db_saved_rev = save_revision(rev)
parents = {} parents = {}
parents[db_saved_rev] = rev.parents unless rev.parents.nil? parents[db_saved_rev] = rev.parents unless rev.parents.nil?
parents.each do |ch, chparents| parents.each do |ch, chparents|
ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
end
end end
end end
h["heads"] = repo_heads.dup end
merge_extra_info(h) h["heads"] = repo_heads.dup
self.save merge_extra_info(h)
self.save
end end
private :save_revisions private :save_revisions