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
|
||||
|
||||
unless changesets.find_by_scmid(scm_revision)
|
||||
|
||||
revisions = scm.revisions('', db_revision, nil)
|
||||
transaction do
|
||||
revisions.reverse_each do |revision|
|
||||
scm.revisions('', db_revision, nil, :reverse => true) do |revision|
|
||||
transaction do
|
||||
changeset = Changeset.create(:repository => self,
|
||||
:revision => revision.identifier,
|
||||
:scmid => revision.scmid,
|
||||
|
|
|
@ -139,10 +139,10 @@ module Redmine
|
|||
def revisions(path, identifier_from, identifier_to, options={})
|
||||
revisions = Revisions.new
|
||||
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 << " #{shell_quote(identifier_from + '..')} " if identifier_from
|
||||
cmd << " #{shell_quote identifier_to} " if identifier_to
|
||||
#cmd << " HEAD " if !identifier_to
|
||||
shellout(cmd) do |io|
|
||||
files=[]
|
||||
changeset = {}
|
||||
|
@ -155,13 +155,18 @@ module Redmine
|
|||
value = $1
|
||||
if (parsing_descr == 1 || parsing_descr == 2)
|
||||
parsing_descr = 0
|
||||
revisions << Revision.new({:identifier => changeset[:commit],
|
||||
:scmid => changeset[:commit],
|
||||
:author => changeset[:author],
|
||||
:time => Time.parse(changeset[:date]),
|
||||
:message => changeset[:description],
|
||||
:paths => files
|
||||
})
|
||||
revision = Revision.new({:identifier => changeset[:commit],
|
||||
:scmid => changeset[:commit],
|
||||
:author => changeset[:author],
|
||||
:time => Time.parse(changeset[:date]),
|
||||
:message => changeset[:description],
|
||||
:paths => files
|
||||
})
|
||||
if block_given?
|
||||
yield revision
|
||||
else
|
||||
revisions << revision
|
||||
end
|
||||
changeset = {}
|
||||
files = []
|
||||
revno = revno + 1
|
||||
|
@ -190,14 +195,20 @@ module Redmine
|
|||
end
|
||||
end
|
||||
|
||||
revisions << Revision.new({:identifier => changeset[:commit],
|
||||
if changeset[:commit]
|
||||
revision = Revision.new({:identifier => changeset[:commit],
|
||||
:scmid => changeset[:commit],
|
||||
:author => changeset[:author],
|
||||
:time => Time.parse(changeset[:date]),
|
||||
:message => changeset[:description],
|
||||
:paths => files
|
||||
}) if changeset[:commit]
|
||||
|
||||
})
|
||||
if block_given?
|
||||
yield revision
|
||||
else
|
||||
revisions << revision
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return nil if $? && $?.exitstatus != 0
|
||||
|
|
Loading…
Reference in New Issue