diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 083031e06..0f9938eb2 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -439,6 +439,39 @@ class BazaarDownloadStrategy <AbstractDownloadStrategy end end +class FossilDownloadStrategy < AbstractDownloadStrategy + def initialize url, name, version, specs + super + @unique_token="#{name}--fossil" unless name.to_s.empty? or name == '__UNKNOWN__' + @clone=HOMEBREW_CACHE+@unique_token + end + + def cached_location; @clone; end + + def fetch + raise "You must install fossil first" \ + unless system "/usr/bin/which fossil" + + ohai "Cloning #{@url}" + unless @clone.exist? + url=@url.sub(%r[^fossil://], '') + safe_system 'fossil', 'clone', url, @clone + else + puts "Updating #{@clone}" + safe_system 'fossil', 'pull', '-R', @clone + end + end + + def stage + # TODO: The 'open' and 'checkout' commands are very noisy and have no '-q' option. + safe_system 'fossil', 'open', @clone + if @spec and @ref + ohai "Checking out #{@spec} #{@ref}" + safe_system 'fossil', 'checkout', @ref + end + end +end + def detect_download_strategy url case url # We use a special URL pattern for cvs @@ -449,6 +482,7 @@ def detect_download_strategy url when %r[^hg://] then MercurialDownloadStrategy when %r[^svn://] then SubversionDownloadStrategy when %r[^svn+http://] then SubversionDownloadStrategy + when %r[^fossil://] then FossilDownloadStrategy # Some well-known source hosts when %r[^http://github\.com/.+\.git$] then GitDownloadStrategy when %r[^https?://(.+?\.)?googlecode\.com/hg] then MercurialDownloadStrategy |
