diff options
| author | Jack Nagel | 2013-09-28 17:00:42 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-09-28 17:08:48 -0500 |
| commit | 7deb2f85e82c43f6927f8e89f8f81fb10ddbecef (patch) | |
| tree | c51a14719290b766d126bac8ef3bd3b5c67ea149 /Library | |
| parent | c5289f25039107a0c73a0abb66bd8e3e06782c10 (diff) | |
| download | brew-7deb2f85e82c43f6927f8e89f8f81fb10ddbecef.tar.bz2 | |
MercurialDownloadStrategy: handle corrupt checkouts
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 124c15fb0..29edbfb3b 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -631,18 +631,30 @@ class MercurialDownloadStrategy < AbstractDownloadStrategy def fetch ohai "Cloning #{@url}" - unless @clone.exist? - url=@url.sub(%r[^hg://], '') - safe_system hgpath, 'clone', url, @clone - else + if @clone.exist? && repo_valid? puts "Updating #{@clone}" - Dir.chdir(@clone) do + @clone.cd do safe_system hgpath, 'pull' safe_system hgpath, 'update' end + elsif @clone.exist? + puts "Removing invalid hg repo from cache" + @clone.rmtree + clone_repo + else + clone_repo 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 dst=Dir.getwd Dir.chdir @clone do |
