]> source.dussan.org Git - redmine.git/commitdiff
scm: git: backout r8840 (#8857, #9472)
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 7 Mar 2012 05:57:29 +0000 (05:57 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Wed, 7 Mar 2012 05:57:29 +0000 (05:57 +0000)
reduce saving heads times in fetching revisions.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9141 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/repository/git.rb

index 6dae13e9cf78de84e461c6f5b9dd9419f8fa83ea..d777fe7c5b0d1a631c5ba5367f0f87160f9a01bd 100644 (file)
@@ -162,12 +162,10 @@ class Repository::Git < Repository
     opts[:excludes] = prev_db_heads
     opts[:includes] = repo_heads
     begin
-      cnt = 0
       scm.revisions('', nil, nil, opts) do |rev|
-        cnt += 1
         db_rev = find_changeset_by_name(rev.scmid)
-        if db_rev.nil?
-          transaction do
+        transaction do
+          if db_rev.nil?
             db_saved_rev = save_revision(rev)
             parents = {}
             parents[db_saved_rev] = rev.parents unless rev.parents.nil?
@@ -175,9 +173,6 @@ class Repository::Git < Repository
               ch.parents = chparents.collect{|rp| find_changeset_by_name(rp)}.compact
             end
           end
-        end
-        if cnt > 100
-          cnt = 0
           h["heads"] = prev_db_heads.dup
           h["heads"] << rev.scmid
           merge_extra_info(h)