From 2f18fff9992d9f53a1cda4c4108d7c08a9d77e9c Mon Sep 17 00:00:00 2001 From: feu Date: Wed, 25 Jul 2018 16:42:16 -0300 Subject: [PATCH] adjusting svn commands to consider the @ symbol --- Library/Homebrew/download_strategy.rb | 33 +++++++++++++++---- .../Homebrew/unpack_strategy/subversion.rb | 4 ++- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index c63210bc98..eecd2797af 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -131,7 +131,7 @@ class VCSDownloadStrategy < AbstractDownloadStrategy end def cached_location - @clone + @clone end delegate head?: :version @@ -554,18 +554,37 @@ class SubversionDownloadStrategy < VCSDownloadStrategy end def source_modified_time - xml = REXML::Document.new(Utils.popen_read("svn", "info", "--xml", cached_location.to_s)) + xml = REXML::Document.new(Utils.popen_read("svn", "info", "--xml", svn_cached_location)) Time.parse REXML::XPath.first(xml, "//date/text()").to_s end def last_commit - Utils.popen_read("svn", "info", "--show-item", "revision", cached_location.to_s).strip + Utils.popen_read("svn", "info", "--show-item", "revision", svn_cached_location).strip end private - def repo_url - Utils.popen_read("svn", "info", cached_location.to_s).strip[/^URL: (.+)$/, 1] + def escape(svn_url) + # subversion uses '@' to point to a specific revision + # so when the path contains a @, it requires an additional @ at the end + # but this is not consistent through all commands + # the commands are affected as follows: + # svn checkout url1 foo@a # properly checks out url1 to foo@a + # svn switch url2 foo@a # properly switchs foo@a to url2 + # svn update foo@a@ # properly updates foo@a + # svn info foo@a@ # properly obtains info on foo@a + # svn export foo@a@ newdir # properly export foo@a contents to newdir + result = svn_url.to_s.dup + result << "@" if result.include? "@" + result + end + + def svn_cached_location + escape(cached_location) + end + + def repo_url + Utils.popen_read("svn", "info", svn_cached_location).strip[/^URL: (.+)$/, 1] end def externals @@ -582,7 +601,9 @@ class SubversionDownloadStrategy < VCSDownloadStrategy svncommand = target.directory? ? "up" : "checkout" args = ["svn", svncommand] args << url unless target.directory? - args << target + target_arg = target.to_s + target_arg = escape(target_arg) if svncommand == "up" + args << target_arg if revision ohai "Checking out #{@ref}" args << "-r" << revision diff --git a/Library/Homebrew/unpack_strategy/subversion.rb b/Library/Homebrew/unpack_strategy/subversion.rb index 02599f01e2..90c81eb552 100644 --- a/Library/Homebrew/unpack_strategy/subversion.rb +++ b/Library/Homebrew/unpack_strategy/subversion.rb @@ -9,7 +9,9 @@ module UnpackStrategy private def extract_to_dir(unpack_dir, basename:, verbose:) - system_command! "svn", args: ["export", "--force", path, unpack_dir] + path_export = path.to_s + path_export << "@" if path_export.include? "@" + system_command! "svn", args: ["export", "--force", path_export, unpack_dir] end end end