diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-03-12 20:28:49 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-03-12 20:28:49 +0000 |
commit | 3a9b0988c7515371531e47f9eef9f8e60ce352aa (patch) | |
tree | 2a2deaedbd321dcf838c631dfed357f3c1110dbe /app/models/repository/cvs.rb | |
parent | 6fcc512cb77a0851ab8c3c693fd178b564a600dd (diff) | |
download | redmine-3a9b0988c7515371531e47f9eef9f8e60ce352aa.tar.gz redmine-3a9b0988c7515371531e47f9eef9f8e60ce352aa.zip |
Merged Git support branch (r1200 to r1226).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1236 e93f8b46-1217-0410-a6f0-8f06a7374b81
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 |