##// END OF EJS Templates
scm: git: fix model source indents (#10470)...
Toshi MARUYAMA -
r9150:5232d379f97e
parent child
Show More
@@ -155,56 +155,56 class Repository::Git < Repository
155 end
155 end
156
156
157 def save_revisions(prev_db_heads, repo_heads)
157 def save_revisions(prev_db_heads, repo_heads)
158 h = {}
158 h = {}
159 opts = {}
159 opts = {}
160 opts[:reverse] = true
160 opts[:reverse] = true
161 opts[:excludes] = prev_db_heads
161 opts[:excludes] = prev_db_heads
162 opts[:includes] = repo_heads
162 opts[:includes] = repo_heads
163
163
164 revisions = scm.revisions('', nil, nil, opts)
164 revisions = scm.revisions('', nil, nil, opts)
165 return if revisions.blank?
165 return if revisions.blank?
166
166
167 # Make the search for existing revisions in the database in a more sufficient manner
167 # Make the search for existing revisions in the database in a more sufficient manner
168 # This is replacing the one-after-one queries.
168 # This is replacing the one-after-one queries.
169 # Find all revisions, that are in the database, and then remove them from the revision array.
169 # Find all revisions, that are in the database, and then remove them from the revision array.
170 # Then later we won't need any conditions for db existence.
170 # Then later we won't need any conditions for db existence.
171 # Query for several revisions at once, and remove them from the revisions array, if they are there.
171 # Query for several revisions at once, and remove them from the revisions array, if they are there.
172 # Do this in chunks, to avoid eventual memory problems (in case of tens of thousands of commits).
172 # Do this in chunks, to avoid eventual memory problems (in case of tens of thousands of commits).
173 # If there are no revisions (because the original code's algoritm filtered them),
173 # If there are no revisions (because the original code's algoritm filtered them),
174 # then this part will be stepped over.
174 # then this part will be stepped over.
175 # We make queries, just if there is any revision.
175 # We make queries, just if there is any revision.
176 limit = 100
176 limit = 100
177 offset = 0
177 offset = 0
178 revisions_copy = revisions.clone # revisions will change
178 revisions_copy = revisions.clone # revisions will change
179 while offset < revisions_copy.size
179 while offset < revisions_copy.size
180 recent_changesets_slice = changesets.find(
180 recent_changesets_slice = changesets.find(
181 :all,
181 :all,
182 :conditions => [
182 :conditions => [
183 'scmid IN (?)',
183 'scmid IN (?)',
184 revisions_copy.slice(offset, limit).map{|x| x.scmid}
184 revisions_copy.slice(offset, limit).map{|x| x.scmid}
185 ]
185 ]
186 )
186 )
187 # Subtract revisions that redmine already knows about
187 # Subtract revisions that redmine already knows about
188 recent_revisions = recent_changesets_slice.map{|c| c.scmid}
188 recent_revisions = recent_changesets_slice.map{|c| c.scmid}
189 revisions.reject!{|r| recent_revisions.include?(r.scmid)}
189 revisions.reject!{|r| recent_revisions.include?(r.scmid)}
190 offset += limit
190 offset += limit
191 end
191 end
192
192
193 revisions.each do |rev|
193 revisions.each do |rev|
194 transaction do
194 transaction do
195 # There is no search in the db for this revision, because above we ensured,
195 # There is no search in the db for this revision, because above we ensured,
196 # that it's not in the db.
196 # that it's not in the db.
197 db_saved_rev = save_revision(rev)
197 db_saved_rev = save_revision(rev)
198 parents = {}
198 parents = {}
199 parents[db_saved_rev] = rev.parents unless rev.parents.nil?
199 parents[db_saved_rev] = rev.parents unless rev.parents.nil?
200 parents.each do |ch, chparents|
200 parents.each do |ch, chparents|
201 ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
201 ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
202 end
203 end
202 end
204 end
203 end
205 h["heads"] = repo_heads.dup
204 end
206 merge_extra_info(h)
205 h["heads"] = repo_heads.dup
207 self.save
206 merge_extra_info(h)
207 self.save
208 end
208 end
209 private :save_revisions
209 private :save_revisions
210
210
General Comments 0
You need to be logged in to leave comments. Login now