aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorTianyi Cui2010-09-29 20:22:34 +0800
committerAdam Vandenberg2010-10-03 09:11:14 -0700
commit915b018e159569b2dcf39388e5ef0af985b34402 (patch)
tree056f7e83fcddab7e54d08c4e187306ffdbc45169 /Library/Homebrew
parent25f6bffa3097e420193a8f427eacdf9f8f045556 (diff)
downloadbrew-915b018e159569b2dcf39388e5ef0af985b34402.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/Homebrew')
-rw-r--r--Library/Homebrew/download_strategy.rb34
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