@@ -155,56 +155,56 class Repository::Git < Repository | |||
|
155 | 155 | end |
|
156 | 156 | |
|
157 | 157 | def save_revisions(prev_db_heads, repo_heads) |
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
|
163 | ||
|
164 |
|
|
|
165 |
|
|
|
166 | ||
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
158 | h = {} | |
|
159 | opts = {} | |
|
160 | opts[:reverse] = true | |
|
161 | opts[:excludes] = prev_db_heads | |
|
162 | opts[:includes] = repo_heads | |
|
163 | ||
|
164 | revisions = scm.revisions('', nil, nil, opts) | |
|
165 | return if revisions.blank? | |
|
166 | ||
|
167 | # Make the search for existing revisions in the database in a more sufficient manner | |
|
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. | |
|
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. | |
|
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), | |
|
174 | # then this part will be stepped over. | |
|
175 | # We make queries, just if there is any revision. | |
|
176 | limit = 100 | |
|
177 | offset = 0 | |
|
178 | revisions_copy = revisions.clone # revisions will change | |
|
179 | while offset < revisions_copy.size | |
|
180 | recent_changesets_slice = changesets.find( | |
|
181 | 181 | :all, |
|
182 | 182 | :conditions => [ |
|
183 | 183 | 'scmid IN (?)', |
|
184 | 184 | revisions_copy.slice(offset, limit).map{|x| x.scmid} |
|
185 | 185 | ] |
|
186 | 186 | ) |
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
187 | # Subtract revisions that redmine already knows about | |
|
188 | recent_revisions = recent_changesets_slice.map{|c| c.scmid} | |
|
189 | revisions.reject!{|r| recent_revisions.include?(r.scmid)} | |
|
190 | offset += limit | |
|
191 | end | |
|
192 | 192 | |
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 | end | |
|
193 | revisions.each do |rev| | |
|
194 | transaction do | |
|
195 | # There is no search in the db for this revision, because above we ensured, | |
|
196 | # that it's not in the db. | |
|
197 | db_saved_rev = save_revision(rev) | |
|
198 | parents = {} | |
|
199 | parents[db_saved_rev] = rev.parents unless rev.parents.nil? | |
|
200 | parents.each do |ch, chparents| | |
|
201 | ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact | |
|
203 | 202 | end |
|
204 | 203 | end |
|
205 | h["heads"] = repo_heads.dup | |
|
206 | merge_extra_info(h) | |
|
207 | self.save | |
|
204 | end | |
|
205 | h["heads"] = repo_heads.dup | |
|
206 | merge_extra_info(h) | |
|
207 | self.save | |
|
208 | 208 | end |
|
209 | 209 | private :save_revisions |
|
210 | 210 |
General Comments 0
You need to be logged in to leave comments.
Login now