scm: cvs: code clean up model.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5450 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-04-13 11:54:42 +00:00
parent 12c856124b
commit b091c98238
1 changed files with 26 additions and 25 deletions

View File

@ -124,8 +124,7 @@ class Repository::Cvs < Repository
# last one is the next step to take. the commit-date is not equal for all # last one is the next step to take. the commit-date is not equal for all
# commits in one changeset. cvs update the commit-date when the *,v file was touched. so # commits in one changeset. cvs update the commit-date when the *,v file was touched. so
# we use a small delta here, to merge all changes belonging to _one_ changeset # we use a small delta here, to merge all changes belonging to _one_ changeset
time_delta=10.seconds time_delta = 10.seconds
fetch_since = latest_changeset ? latest_changeset.committed_on : nil fetch_since = latest_changeset ? latest_changeset.committed_on : nil
transaction do transaction do
tmp_rev_num = 1 tmp_rev_num = 1
@ -134,14 +133,18 @@ class Repository::Cvs < Repository
# is not exclusive at all. # is not exclusive at all.
tmp_time = revision.time.clone tmp_time = revision.time.clone
unless changes.find_by_path_and_revision( unless changes.find_by_path_and_revision(
scm.with_leading_slash(revision.paths[0][:path]), revision.paths[0][:revision]) scm.with_leading_slash(revision.paths[0][:path]),
revision.paths[0][:revision]
)
cmt = Changeset.normalize_comments(revision.message, repo_log_encoding) cmt = Changeset.normalize_comments(revision.message, repo_log_encoding)
cs = changesets.find(:first, :conditions=>{ cs = changesets.find(
:committed_on=>tmp_time - time_delta .. tmp_time + time_delta, :first,
:committer=>revision.author, :conditions => {
:comments=>cmt :committed_on => tmp_time - time_delta .. tmp_time + time_delta,
}) :committer => revision.author,
:comments => cmt
}
)
# create a new changeset.... # create a new changeset....
unless cs unless cs
# we use a temporaray revision number here (just for inserting) # we use a temporaray revision number here (just for inserting)
@ -157,16 +160,14 @@ class Repository::Cvs < Repository
:comments => revision.message) :comments => revision.message)
tmp_rev_num += 1 tmp_rev_num += 1
end end
# convert CVS-File-States to internal Action-abbrevations
#convert CVS-File-States to internal Action-abbrevations # default action is (M)odified
#default action is (M)odified action = "M"
action="M" if revision.paths[0][:action] == "Exp" && revision.paths[0][:revision] == "1.1"
if revision.paths[0][:action]=="Exp" && revision.paths[0][:revision]=="1.1" action = "A" # add-action always at first revision (= 1.1)
action="A" #add-action always at first revision (= 1.1) elsif revision.paths[0][:action] == "dead"
elsif revision.paths[0][:action]=="dead" action = "D" # dead-state is similar to Delete
action="D" #dead-state is similar to Delete
end end
Change.create( Change.create(
:changeset => cs, :changeset => cs,
:action => action, :action => action,