]> source.dussan.org Git - redmine.git/commitdiff
scm: mercurial: git: save parents in creating changesets (#10470)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 3 Apr 2012 08:05:30 +0000 (08:05 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 3 Apr 2012 08:05:30 +0000 (08:05 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9311 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/repository/git.rb
app/models/repository/mercurial.rb

index 37104cbf04e254fc569dfea4c7f2da98ac3f1191..43c82656274d80440a2abeec13b4bc100d2278a5 100644 (file)
@@ -218,21 +218,18 @@ class Repository::Git < Repository
   private :save_revisions
 
   def save_revision(rev)
+    parents = (rev.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact
     changeset = Changeset.create(
               :repository   => self,
               :revision     => rev.identifier,
               :scmid        => rev.scmid,
               :committer    => rev.author,
               :committed_on => rev.time,
-              :comments     => rev.message
+              :comments     => rev.message,
+              :parents      => parents
               )
     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
   end
index c31682783717e540dd5e3e4cc147264fe9c102d8..36dfb201f321ecf05cfed0abc739cc0ff7b2894c 100644 (file)
@@ -140,19 +140,16 @@ class Repository::Mercurial < Repository
     (db_rev + 1).step(scm_rev, FETCH_AT_ONCE) do |i|
       scm.each_revision('', i, [i + FETCH_AT_ONCE - 1, scm_rev].min) do |re|
         transaction do
+          parents = (re.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact
           cs = Changeset.create(:repository   => self,
                                 :revision     => re.revision,
                                 :scmid        => re.scmid,
                                 :committer    => re.author,
                                 :committed_on => re.time,
-                                :comments     => re.message)
+                                :comments     => re.message,
+                                :parents      => parents)
           unless cs.new_record?
             re.paths.each { |e| cs.create_change(e) }
-            parents = {}
-            parents[cs] = re.parents unless re.parents.nil?
-            parents.each do |ch, chparents|
-              ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
-            end
           end
         end
       end