From b091c98238495e7c696efc87348dec4199edac14 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Wed, 13 Apr 2011 11:54:42 +0000 Subject: [PATCH] scm: cvs: code clean up model. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5450 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/repository/cvs.rb | 51 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb index d2504ff06..4112f3ecd 100644 --- a/app/models/repository/cvs.rb +++ b/app/models/repository/cvs.rb @@ -124,8 +124,7 @@ class Repository::Cvs < Repository # 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 # 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 transaction do tmp_rev_num = 1 @@ -134,39 +133,41 @@ class Repository::Cvs < Repository # 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]) + scm.with_leading_slash(revision.paths[0][:path]), + revision.paths[0][:revision] + ) cmt = Changeset.normalize_comments(revision.message, repo_log_encoding) - cs = changesets.find(:first, :conditions=>{ - :committed_on=>tmp_time - time_delta .. tmp_time + time_delta, - :committer=>revision.author, - :comments=>cmt - }) - + cs = changesets.find( + :first, + :conditions => { + :committed_on => tmp_time - time_delta .. tmp_time + time_delta, + :committer => revision.author, + :comments => cmt + } + ) # create a new changeset.... 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}", - :scmid => scmid, - :committer => revision.author, + 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}", + :scmid => scmid, + :committer => revision.author, :committed_on => tmp_time, - :comments => revision.message) + :comments => revision.message) tmp_rev_num += 1 end - - #convert CVS-File-States to internal Action-abbrevations - #default action is (M)odified - action="M" - if revision.paths[0][:action]=="Exp" && revision.paths[0][:revision]=="1.1" - action="A" #add-action always at first revision (= 1.1) - elsif revision.paths[0][:action]=="dead" - action="D" #dead-state is similar to Delete + # convert CVS-File-States to internal Action-abbrevations + # default action is (M)odified + action = "M" + if revision.paths[0][:action] == "Exp" && revision.paths[0][:revision] == "1.1" + action = "A" # add-action always at first revision (= 1.1) + elsif revision.paths[0][:action] == "dead" + action = "D" # dead-state is similar to Delete end - Change.create( :changeset => cs, :action => action,