diff options
Diffstat (limited to 'app/models/repository/cvs.rb')
-rw-r--r-- | app/models/repository/cvs.rb | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb index 16d906316..a78b60806 100644 --- a/app/models/repository/cvs.rb +++ b/app/models/repository/cvs.rb @@ -82,9 +82,6 @@ class Repository::Cvs < Repository end def fetch_changesets - #not the preferred way with CVS. maybe we should introduce always a cron-job for this - last_commit = changesets.maximum(:committed_on) - # some nifty bits to introduce a commit-id with cvs # natively cvs doesn't provide any kind of changesets, there is only a revision per file. # we now take a guess using the author, the commitlog and the commit-date. @@ -94,8 +91,10 @@ class Repository::Cvs < Repository # we use a small delta here, to merge all changes belonging to _one_ changeset time_delta=10.seconds + fetch_since = latest_changeset ? latest_changeset.committed_on : nil transaction do - scm.revisions('', last_commit, nil, :with_paths => true) do |revision| + tmp_rev_num = 1 + scm.revisions('', fetch_since, nil, :with_paths => true) do |revision| # only add the change to the database, if it doen't exists. the cvs log # is not exclusive at all. unless changes.find_by_path_and_revision(scm.with_leading_slash(revision.paths[0][:path]), revision.paths[0][:revision]) @@ -107,18 +106,16 @@ class Repository::Cvs < Repository }) # create a new changeset.... - unless cs - # we use a negative changeset-number here (just for inserting) + unless cs + # we use a temporaray revision number here (just for inserting) # later on, we calculate a continous positive number - next_rev = changesets.minimum(:revision) - next_rev = 0 if next_rev.nil? or next_rev > 0 - next_rev = next_rev - 1 - - cs=Changeset.create(:repository => self, - :revision => next_rev, - :committer => revision.author, - :committed_on => revision.time, - :comments => revision.message) + latest = changesets.find(:first, :order => 'id DESC') + cs = Changeset.create(:repository => self, + :revision => "_#{tmp_rev_num}", + :committer => revision.author, + :committed_on => revision.time, + :comments => revision.message) + tmp_rev_num += 1 end #convert CVS-File-States to internal Action-abbrevations @@ -139,12 +136,13 @@ class Repository::Cvs < Repository end end - next_rev = [changesets.maximum(:revision) || 0, 0].max - changesets.find(:all, :conditions=>["revision < 0"], :order=>"committed_on ASC").each() do |changeset| - next_rev = next_rev + 1 - changeset.revision = next_rev - changeset.save! + # Renumber new changesets in chronological order + c = changesets.find(:first, :order => 'committed_on DESC, id DESC', :conditions => "revision NOT LIKE '_%'") + next_rev = c.nil? ? 1 : (c.revision.to_i + 1) + changesets.find(:all, :order => 'committed_on ASC, id ASC', :conditions => "revision LIKE '_%'").each do |changeset| + changeset.update_attribute :revision, next_rev + next_rev += 1 end - end + end # transaction end end |