diff options
| author | Fergal Hainey | 2010-02-14 14:51:54 +0000 |
|---|---|---|
| committer | Adam Vandenberg | 2010-03-01 09:59:25 -0800 |
| commit | 69bc0cbf677509e539c6ecc7cac90e55a9303225 (patch) | |
| tree | eff0bf071b7efe823a8ff5e0abee7b9b7764dabf | |
| parent | 5e1632c1e2902eee3bc4f28b26c8ad375a257b05 (diff) | |
| download | brew-69bc0cbf677509e539c6ecc7cac90e55a9303225.tar.bz2 | |
Improvements to new SubversionDownloadStrategy
Now makes use of `svn up` to make cache act like
a cache. Externals without a revision specified
are now checked out at HEAD, whereas before they
were ignored. Escaping arguments to backticks.
Making sure main repo is checked out before the
externals.
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index b49cf4d6e..5657924e6 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -142,21 +142,47 @@ end class SubversionDownloadStrategy <AbstractDownloadStrategy def fetch + # Looks like `svn up` is pretty cool, as it will save on bandwidth (makes + # cache actually a cache) and will have a similar effect to verifying the + # cache as it will make any changes to get the right revision. ohai "Checking out #{@url}" - @co=HOMEBREW_CACHE+@unique_token - unless @co.exist? - quiet_safe_system svn, 'checkout', @url, @co + if @spec == :revision + svncommand = @export.exist? ? 'up' : 'checkout'; + args = [svn, svncommand, '--force', @url, @export] + args << '-r' << @ref if @ref + quiet_safe_system *args + elsif @spec == :revisions + externals = Hash.new + # Oh god escaping shell args. + # See http://notetoself.vrensk.com/2008/08/escaping-single-quotes-in-ruby-harder-than-expected/ + `'#{svn.gsub(/\\|'/) { |c| "\\#{c}" }}' propget svn:externals \ + '#{@url.gsub(/\\|'/) { |c| "\\#{c}" }}'`.each_line do |external_line| + key, value = external_line.split /\s+/ + externals[key] = value + end + fetch_repo = lambda do |external, uri| + if external.to_s == @name + path = '' + else + path = external.to_s + end + svncommand = (@export+path).exist? ? 'up' : 'checkout'; + args = [svn, svncommand, '--force', '--ignore-externals', uri, @export+path] + args << '-r' << @ref[external] if @ref[external] + quiet_safe_system *args + end + fetch_repo.call @name, @url + externals.each_pair &fetch_repo else - puts "Updating #{@co}" - quiet_safe_system svn, 'up', @co + svncommand = @export.exist? ? 'up' : 'checkout'; + args = [svn, svncommand, '--force', @url, @export] + quiet_safe_system *args end end def stage - # Force the export, since the target directory will already exist - args = [svn, 'export', '--force', @co, Dir.pwd] - args << '-r' << @ref if @spec == :revision and @ref - quiet_safe_system *args + # `svn export PATH1 PATH2` doesn't need network when no revision is given. + quiet_safe_system svn, 'export', '--force', @export, Dir.pwd end # Override this method in a DownloadStrategy to force the use of a non- |
