Skip to content

Commit

Permalink
scm: git: use Changeset#create and Changeset#create_change as same wi…
Browse files Browse the repository at this point in the history
…th Subversion and Mercurial

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9290 e93f8b46-1217-0410-a6f0-8f06a7374b81
  • Loading branch information
marutosi committed Mar 29, 2012
1 parent cdb7ea8 commit f36eb54
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions app/models/repository/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,7 @@ def save_revisions(prev_db_heads, repo_heads)
transaction do
# There is no search in the db for this revision, because above we ensured,
# that it's not in the db.
db_saved_rev = save_revision(rev)
parents = {}
parents[db_saved_rev] = rev.parents unless rev.parents.nil?
parents.each do |ch, chparents|
ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
end
save_revision(rev)
end
end
h["heads"] = repo_heads.dup
Expand All @@ -223,20 +218,20 @@ def save_revisions(prev_db_heads, repo_heads)
private :save_revisions

def save_revision(rev)
changeset = Changeset.new(
changeset = Changeset.create(
:repository => self,
:revision => rev.identifier,
:scmid => rev.scmid,
:committer => rev.author,
:committed_on => rev.time,
:comments => rev.message
)
if changeset.save
rev.paths.each do |file|
Change.create(
:changeset => changeset,
:action => file[:action],
:path => file[:path])
unless changeset.new_record?
rev.paths.each { |change| changeset.create_change(change) }
parents = {}
parents[changeset] = rev.parents unless rev.parents.nil?
parents.each do |ch, chparents|
ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
end
end
changeset
Expand Down

0 comments on commit f36eb54

Please sign in to comment.