diff options
| author | Tianyi Cui | 2010-09-29 20:22:34 +0800 |
|---|---|---|
| committer | Adam Vandenberg | 2010-10-03 09:11:14 -0700 |
| commit | 54de1d2d422f8c95a445054f255bd300dff50019 (patch) | |
| tree | 2431d4dba05ee3feb029505b7688156cadac0fa8 /Library | |
| parent | eddafe2c5f6f7c3993549834c25c17de992173eb (diff) | |
| download | homebrew-54de1d2d422f8c95a445054f255bd300dff50019.tar.bz2 | |
Added FossilDownloadStrategy (Fossil SCM support)
This will enable downloading source repository using fossil SCM.
For example, formulae `fossil` and `mongrel2` can have HEAD version.
Signed-off-by: Adam Vandenberg <flangy@gmail.com>
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 |
