MercurialDownloadStrategy: handle corrupt checkouts
This commit is contained in:
parent
c5289f2503
commit
7deb2f85e8
@ -631,18 +631,30 @@ class MercurialDownloadStrategy < AbstractDownloadStrategy
|
|||||||
def fetch
|
def fetch
|
||||||
ohai "Cloning #{@url}"
|
ohai "Cloning #{@url}"
|
||||||
|
|
||||||
unless @clone.exist?
|
if @clone.exist? && repo_valid?
|
||||||
url=@url.sub(%r[^hg://], '')
|
|
||||||
safe_system hgpath, 'clone', url, @clone
|
|
||||||
else
|
|
||||||
puts "Updating #{@clone}"
|
puts "Updating #{@clone}"
|
||||||
Dir.chdir(@clone) do
|
@clone.cd do
|
||||||
safe_system hgpath, 'pull'
|
safe_system hgpath, 'pull'
|
||||||
safe_system hgpath, 'update'
|
safe_system hgpath, 'update'
|
||||||
end
|
end
|
||||||
|
elsif @clone.exist?
|
||||||
|
puts "Removing invalid hg repo from cache"
|
||||||
|
@clone.rmtree
|
||||||
|
clone_repo
|
||||||
|
else
|
||||||
|
clone_repo
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def repo_valid?
|
||||||
|
@clone.join(".hg").directory?
|
||||||
|
end
|
||||||
|
|
||||||
|
def clone_repo
|
||||||
|
url = @url.sub(%r[^hg://], '')
|
||||||
|
safe_system hgpath, 'clone', url, @clone
|
||||||
|
end
|
||||||
|
|
||||||
def stage
|
def stage
|
||||||
dst=Dir.getwd
|
dst=Dir.getwd
|
||||||
Dir.chdir @clone do
|
Dir.chdir @clone do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user