Reduces memory usage when importing large git repositories (#1482).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1599 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a40add57de
commit
00593f2f34
|
@ -44,10 +44,8 @@ class Repository::Git < Repository
|
||||||
scm_revision = scm_info.lastrev.scmid
|
scm_revision = scm_info.lastrev.scmid
|
||||||
|
|
||||||
unless changesets.find_by_scmid(scm_revision)
|
unless changesets.find_by_scmid(scm_revision)
|
||||||
|
scm.revisions('', db_revision, nil, :reverse => true) do |revision|
|
||||||
revisions = scm.revisions('', db_revision, nil)
|
transaction do
|
||||||
transaction do
|
|
||||||
revisions.reverse_each do |revision|
|
|
||||||
changeset = Changeset.create(:repository => self,
|
changeset = Changeset.create(:repository => self,
|
||||||
:revision => revision.identifier,
|
:revision => revision.identifier,
|
||||||
:scmid => revision.scmid,
|
:scmid => revision.scmid,
|
||||||
|
|
|
@ -139,10 +139,10 @@ module Redmine
|
||||||
def revisions(path, identifier_from, identifier_to, options={})
|
def revisions(path, identifier_from, identifier_to, options={})
|
||||||
revisions = Revisions.new
|
revisions = Revisions.new
|
||||||
cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw "
|
cmd = "#{GIT_BIN} --git-dir #{target('')} log --raw "
|
||||||
|
cmd << " --reverse" if options[:reverse]
|
||||||
cmd << " -n #{options[:limit].to_i} " if (!options.nil?) && options[:limit]
|
cmd << " -n #{options[:limit].to_i} " if (!options.nil?) && options[:limit]
|
||||||
cmd << " #{shell_quote(identifier_from + '..')} " if identifier_from
|
cmd << " #{shell_quote(identifier_from + '..')} " if identifier_from
|
||||||
cmd << " #{shell_quote identifier_to} " if identifier_to
|
cmd << " #{shell_quote identifier_to} " if identifier_to
|
||||||
#cmd << " HEAD " if !identifier_to
|
|
||||||
shellout(cmd) do |io|
|
shellout(cmd) do |io|
|
||||||
files=[]
|
files=[]
|
||||||
changeset = {}
|
changeset = {}
|
||||||
|
@ -155,13 +155,18 @@ module Redmine
|
||||||
value = $1
|
value = $1
|
||||||
if (parsing_descr == 1 || parsing_descr == 2)
|
if (parsing_descr == 1 || parsing_descr == 2)
|
||||||
parsing_descr = 0
|
parsing_descr = 0
|
||||||
revisions << Revision.new({:identifier => changeset[:commit],
|
revision = Revision.new({:identifier => changeset[:commit],
|
||||||
:scmid => changeset[:commit],
|
:scmid => changeset[:commit],
|
||||||
:author => changeset[:author],
|
:author => changeset[:author],
|
||||||
:time => Time.parse(changeset[:date]),
|
:time => Time.parse(changeset[:date]),
|
||||||
:message => changeset[:description],
|
:message => changeset[:description],
|
||||||
:paths => files
|
:paths => files
|
||||||
})
|
})
|
||||||
|
if block_given?
|
||||||
|
yield revision
|
||||||
|
else
|
||||||
|
revisions << revision
|
||||||
|
end
|
||||||
changeset = {}
|
changeset = {}
|
||||||
files = []
|
files = []
|
||||||
revno = revno + 1
|
revno = revno + 1
|
||||||
|
@ -190,14 +195,20 @@ module Redmine
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
revisions << Revision.new({:identifier => changeset[:commit],
|
if changeset[:commit]
|
||||||
|
revision = Revision.new({:identifier => changeset[:commit],
|
||||||
:scmid => changeset[:commit],
|
:scmid => changeset[:commit],
|
||||||
:author => changeset[:author],
|
:author => changeset[:author],
|
||||||
:time => Time.parse(changeset[:date]),
|
:time => Time.parse(changeset[:date]),
|
||||||
:message => changeset[:description],
|
:message => changeset[:description],
|
||||||
:paths => files
|
:paths => files
|
||||||
}) if changeset[:commit]
|
})
|
||||||
|
if block_given?
|
||||||
|
yield revision
|
||||||
|
else
|
||||||
|
revisions << revision
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil if $? && $?.exitstatus != 0
|
return nil if $? && $?.exitstatus != 0
|
||||||
|
|
Loading…
Reference in New Issue