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
This commit is contained in:
Eric Davis 2010-02-02 17:02:32 +00:00
parent 358e3194d7
commit 39c585740d
4 changed files with 12 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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?