scm: cvs: generate pseudo scmid for auto issue close text (#6706).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4802 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-02-07 10:26:15 +00:00
parent e9ab2de1e7
commit 109fd2cdfc
2 changed files with 13 additions and 3 deletions

View File

@ -104,10 +104,11 @@ class Repository::Cvs < Repository
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.
tmp_time = revision.time.clone
unless changes.find_by_path_and_revision(
scm.with_leading_slash(revision.paths[0][:path]), revision.paths[0][:revision])
cs = changesets.find(:first, :conditions=>{
:committed_on=>revision.time-time_delta..revision.time+time_delta,
:committed_on=>tmp_time - time_delta .. tmp_time + time_delta,
:committer=>revision.author,
:comments=>Changeset.normalize_comments(revision.message)
})
@ -116,10 +117,14 @@ class Repository::Cvs < Repository
unless cs
# we use a temporaray revision number here (just for inserting)
# later on, we calculate a continous positive number
tmp_time2 = tmp_time.clone.gmtime
branch = revision.paths[0][:branch]
scmid = branch + "-" + tmp_time2.strftime("%Y%m%d-%H%M%S")
cs = Changeset.create(:repository => self,
:revision => "tmp#{tmp_rev_num}",
:revision => "tmp#{tmp_rev_num}",
:scmid => scmid,
:committer => revision.author,
:committed_on => revision.time,
:committed_on => tmp_time,
:comments => revision.message)
tmp_rev_num += 1
end

View File

@ -42,6 +42,9 @@ class RepositoryCvsTest < ActiveSupport::TestCase
assert_equal 5, @repository.changesets.count
assert_equal 14, @repository.changes.count
assert_not_nil @repository.changesets.find_by_comments('Two files changed')
r2 = @repository.changesets.find_by_revision('2')
assert_equal 'v1-20071213-162510', r2.scmid
end
def test_fetch_changesets_incremental
@ -57,6 +60,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
assert_equal '3', rev3_commit.revision
# 2007-12-14 01:27:22 +0900
rev3_committed_on = Time.gm(2007, 12, 13, 16, 27, 22)
assert_equal 'HEAD-20071213-162722', rev3_commit.scmid
assert_equal rev3_committed_on, rev3_commit.committed_on
latest_rev = @repository.latest_changeset
assert_equal rev3_committed_on, latest_rev.committed_on
@ -67,6 +71,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase
assert_equal %w|5 4 3 2 1|, @repository.changesets.collect(&:revision)
rev5_commit = @repository.changesets.find(:first, :order => 'committed_on DESC')
assert_equal 'HEAD-20071213-163001', rev5_commit.scmid
# 2007-12-14 01:30:01 +0900
rev5_committed_on = Time.gm(2007, 12, 13, 16, 30, 1)
assert_equal rev5_committed_on, rev5_commit.committed_on