Wraps changeset creation inside a single transation.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3469 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2010-02-21 14:38:34 +00:00
parent 87bc092d7c
commit 103698b371
1 changed files with 11 additions and 9 deletions

View File

@ -286,21 +286,23 @@ module Redmine
end end
def save(repo) def save(repo)
if repo.changesets.find_by_scmid(scmid.to_s).nil? Changeset.transaction do
changeset = Changeset.create!( changeset = Changeset.new(
:repository => repo, :repository => repo,
:revision => identifier, :revision => identifier,
:scmid => scmid, :scmid => scmid,
:committer => author, :committer => author,
:committed_on => time, :committed_on => time,
:comments => message) :comments => message)
paths.each do |file| if changeset.save
Change.create!( paths.each do |file|
:changeset => changeset, Change.create(
:action => file[:action], :changeset => changeset,
:path => file[:path]) :action => file[:action],
end :path => file[:path])
end
end
end end
end end
end end