##// END OF EJS Templates
CVS duplicate key violation fix (#996, #1098)....
Jean-Philippe Lang -
r1340:76b8d3eff26b
parent child
Show More
@@ -138,12 +138,18 class Repository::Cvs < Repository
138 end
138 end
139
139
140 # Renumber new changesets in chronological order
140 # Renumber new changesets in chronological order
141 c = changesets.find(:first, :order => 'committed_on DESC, id DESC', :conditions => "revision NOT LIKE '_%'")
142 next_rev = c.nil? ? 1 : (c.revision.to_i + 1)
143 changesets.find(:all, :order => 'committed_on ASC, id ASC', :conditions => "revision LIKE '_%'").each do |changeset|
141 changesets.find(:all, :order => 'committed_on ASC, id ASC', :conditions => "revision LIKE '_%'").each do |changeset|
144 changeset.update_attribute :revision, next_rev
142 changeset.update_attribute :revision, next_revision_number
145 next_rev += 1
146 end
143 end
147 end # transaction
144 end # transaction
148 end
145 end
146
147 private
148
149 # Returns the next revision number to assign to a CVS changeset
150 def next_revision_number
151 # Need to retrieve existing revision numbers to sort them as integers
152 @current_revision_number ||= (connection.select_values("SELECT revision FROM #{Changeset.table_name} WHERE repository_id = #{id} AND revision NOT LIKE '_%'").collect(&:to_i).max || 0)
153 @current_revision_number += 1
154 end
149 end
155 end
General Comments 0
You need to be logged in to leave comments. Login now