diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-02-02 17:02:32 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-02-02 17:02:32 +0000 |
commit | 39c585740d45cbe50e3fed8a58834eb82532bea0 (patch) | |
tree | 134c518351e11faf1274becf258726c95ecb656a /app | |
parent | 358e3194d79b9e4503edd48d2179b9f8f2920cd3 (diff) | |
download | redmine-39c585740d45cbe50e3fed8a58834eb82532bea0.tar.gz redmine-39c585740d45cbe50e3fed8a58834eb82532bea0.zip |
Refactor: Extract method to create a Change from a Changeset.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3360 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/changeset.rb | 9 | ||||
-rw-r--r-- | app/models/repository/darcs.rb | 6 | ||||
-rw-r--r-- | app/models/repository/mercurial.rb | 6 | ||||
-rw-r--r-- | app/models/repository/subversion.rb | 6 |
4 files changed, 12 insertions, 15 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb index f7145631e..baa43660c 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -148,6 +148,15 @@ class Changeset < ActiveRecord::Base def self.normalize_comments(str) to_utf8(str.to_s.strip) end + + # Creates a new Change from it's common parameters + def create_change(change) + Change.create(:changeset => self, + :action => change[:action], + :path => change[:path], + :from_path => change[:from_path], + :from_revision => change[:from_revision]) + end private diff --git a/app/models/repository/darcs.rb b/app/models/repository/darcs.rb index 5c8d3871a..43fb02946 100644 --- a/app/models/repository/darcs.rb +++ b/app/models/repository/darcs.rb @@ -85,11 +85,7 @@ class Repository::Darcs < Repository :comments => revision.message) revision.paths.each do |change| - Change.create(:changeset => changeset, - :action => change[:action], - :path => change[:path], - :from_path => change[:from_path], - :from_revision => change[:from_revision]) + changeset.create_change(change) end next_rev += 1 end if revisions diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb index 18cbc9495..107223956 100644 --- a/app/models/repository/mercurial.rb +++ b/app/models/repository/mercurial.rb @@ -78,11 +78,7 @@ class Repository::Mercurial < Repository :comments => revision.message) revision.paths.each do |change| - Change.create(:changeset => changeset, - :action => change[:action], - :path => change[:path], - :from_path => change[:from_path], - :from_revision => change[:from_revision]) + changeset.create_change(change) end end end unless revisions.nil? diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb index 3eec5a611..091d14130 100644 --- a/app/models/repository/subversion.rb +++ b/app/models/repository/subversion.rb @@ -63,11 +63,7 @@ class Repository::Subversion < Repository :comments => revision.message) revision.paths.each do |change| - Change.create(:changeset => changeset, - :action => change[:action], - :path => change[:path], - :from_path => change[:from_path], - :from_revision => change[:from_revision]) + changeset.create_change(change) end unless changeset.new_record? end end unless revisions.nil? |