ruby-changes:32721
From: drbrain <ko1@a...>
Date: Tue, 4 Feb 2014 09:48:46 +0900 (JST)
Subject: [ruby-changes:32721] drbrain:r44799 (trunk): * lib/rubygems: Update to RubyGems 2.2.2 prerelease to check fixes to
drbrain 2014-02-04 09:48:31 +0900 (Tue, 04 Feb 2014) New Revision: 44799 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44799 Log: * lib/rubygems: Update to RubyGems 2.2.2 prerelease to check fixes to CI. * test/rubygems: ditto. Added files: trunk/test/rubygems/test_gem_resolver_composed_set.rb Modified files: trunk/ChangeLog trunk/lib/rubygems/available_set.rb trunk/lib/rubygems/config_file.rb trunk/lib/rubygems/dependency_installer.rb trunk/lib/rubygems/ext/ext_conf_builder.rb trunk/lib/rubygems/installer.rb trunk/lib/rubygems/package/tar_header.rb trunk/lib/rubygems/remote_fetcher.rb trunk/lib/rubygems/request.rb trunk/lib/rubygems/request_set.rb trunk/lib/rubygems/resolver/api_set.rb trunk/lib/rubygems/resolver/best_set.rb trunk/lib/rubygems/resolver/composed_set.rb trunk/lib/rubygems/resolver/git_set.rb trunk/lib/rubygems/resolver/index_set.rb trunk/lib/rubygems/resolver/installer_set.rb trunk/lib/rubygems/resolver/lock_set.rb trunk/lib/rubygems/resolver/set.rb trunk/lib/rubygems/resolver/vendor_set.rb trunk/lib/rubygems/resolver.rb trunk/lib/rubygems/source/git.rb trunk/lib/rubygems/test_case.rb trunk/lib/rubygems/version.rb trunk/test/rubygems/test_gem.rb trunk/test/rubygems/test_gem_ext_ext_conf_builder.rb trunk/test/rubygems/test_gem_installer.rb trunk/test/rubygems/test_gem_package_tar_header.rb trunk/test/rubygems/test_gem_platform.rb trunk/test/rubygems/test_gem_remote_fetcher.rb trunk/test/rubygems/test_gem_request.rb trunk/test/rubygems/test_gem_request_set.rb trunk/test/rubygems/test_gem_resolver.rb trunk/test/rubygems/test_gem_resolver_api_set.rb trunk/test/rubygems/test_gem_resolver_best_set.rb trunk/test/rubygems/test_gem_resolver_git_set.rb trunk/test/rubygems/test_gem_resolver_index_set.rb trunk/test/rubygems/test_gem_resolver_installer_set.rb trunk/test/rubygems/test_gem_source_git.rb trunk/test/rubygems/test_gem_specification.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 44798) +++ ChangeLog (revision 44799) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Feb 4 09:47:57 2014 Eric Hodel <drbrain@s...> + + * lib/rubygems: Update to RubyGems 2.2.2 prerelease to check fixes to + CI. + * test/rubygems: ditto. + Mon Feb 3 12:04:47 2014 Kazuhiro NISHIYAMA <zn@m...> * error.c: [DOC] Exception#cause may return nil. [ci skip] Index: lib/rubygems/available_set.rb =================================================================== --- lib/rubygems/available_set.rb (revision 44798) +++ lib/rubygems/available_set.rb (revision 44799) @@ -4,9 +4,12 @@ class Gem::AvailableSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/available_set.rb#L4 Tuple = Struct.new(:spec, :source) + attr_accessor :remote # :nodoc: + def initialize @set = [] @sorted = nil + @remote = true end attr_reader :set Index: lib/rubygems/dependency_installer.rb =================================================================== --- lib/rubygems/dependency_installer.rb (revision 44798) +++ lib/rubygems/dependency_installer.rb (revision 44799) @@ -419,6 +419,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L419 request_set = as.to_request_set install_development_deps request_set.soft_missing = @force + request_set.remote = false unless consider_remote? installer_set = Gem::Resolver::InstallerSet.new @domain installer_set.always_install.concat request_set.always_install Index: lib/rubygems/ext/ext_conf_builder.rb =================================================================== --- lib/rubygems/ext/ext_conf_builder.rb (revision 44798) +++ lib/rubygems/ext/ext_conf_builder.rb (revision 44799) @@ -34,7 +34,11 @@ class Gem::Ext::ExtConfBuilder < Gem::Ex https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/ext_conf_builder.rb#L34 ENV["RUBYOPT"] = ["-r#{siteconf_path}", rubyopt].compact.join(' ') cmd = [Gem.ruby, File.basename(extension), *args].join ' ' - run cmd, results + begin + run cmd, results + ensure + FileUtils.mv 'mkmf.log', dest_path if File.exist? 'mkmf.log' + end ENV["DESTDIR"] = nil ENV["RUBYOPT"] = rubyopt Index: lib/rubygems/request_set.rb =================================================================== --- lib/rubygems/request_set.rb (revision 44798) +++ lib/rubygems/request_set.rb (revision 44799) @@ -39,6 +39,11 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L39 attr_accessor :ignore_dependencies ## + # When false no remote sets are used for resolving gems. + + attr_accessor :remote + + ## # Sets used for resolution attr_reader :sets # :nodoc: @@ -71,6 +76,7 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L76 @git_set = nil @ignore_dependencies = false @install_dir = Gem.dir + @remote = true @requests = [] @sets = [] @soft_missing = false @@ -150,6 +156,7 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L156 gemdeps = options[:gemdeps] @install_dir = options[:install_dir] || Gem.dir + @remote = options[:domain] != :local load_gemdeps gemdeps, options[:without_groups] @@ -235,6 +242,7 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L242 @sets << @vendor_set set = Gem::Resolver.compose_sets(*@sets) + set.remote = @remote resolver = Gem::Resolver.new @dependencies, set resolver.development = @development Index: lib/rubygems/config_file.rb =================================================================== --- lib/rubygems/config_file.rb (revision 44798) +++ lib/rubygems/config_file.rb (revision 44799) @@ -137,9 +137,10 @@ class Gem::ConfigFile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/config_file.rb#L137 attr_reader :ssl_verify_mode ## - # Path name of directory or file of openssl CA certificate, used for remote https connection + # Path name of directory or file of openssl CA certificate, used for remote + # https connection - attr_reader :ssl_ca_cert + attr_accessor :ssl_ca_cert ## # Path name of directory or file of openssl client certificate, used for remote https connection with client authentication Index: lib/rubygems/package/tar_header.rb =================================================================== --- lib/rubygems/package/tar_header.rb (revision 44798) +++ lib/rubygems/package/tar_header.rb (revision 44799) @@ -134,7 +134,7 @@ class Gem::Package::TarHeader https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package/tar_header.rb#L134 vals[:gid] ||= 0 vals[:mtime] ||= 0 vals[:checksum] ||= "" - vals[:typeflag] ||= "0" + vals[:typeflag] = "0" if vals[:typeflag].nil? || vals[:typeflag].empty? vals[:magic] ||= "ustar" vals[:version] ||= "00" vals[:uname] ||= "wheel" Index: lib/rubygems/source/git.rb =================================================================== --- lib/rubygems/source/git.rb (revision 44798) +++ lib/rubygems/source/git.rb (revision 44799) @@ -24,6 +24,11 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L24 attr_reader :reference ## + # When false the cache for this repository will not be updated. + + attr_accessor :remote + + ## # The git repository this gem is sourced from. attr_reader :repository @@ -53,6 +58,7 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L58 @reference = reference @need_submodules = submodules + @remote = true @root_dir = Gem.dir @git = ENV['git'] || 'git' end @@ -85,6 +91,8 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L91 def checkout # :nodoc: cache + return false unless File.exist? repo_cache_dir + unless File.exist? install_dir then system @git, 'clone', '--quiet', '--no-checkout', repo_cache_dir, install_dir @@ -107,6 +115,8 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L115 # Creates a local cache repository for the git gem. def cache # :nodoc: + return unless @remote + if File.exist? repo_cache_dir then Dir.chdir repo_cache_dir do system @git, 'fetch', '--quiet', '--force', '--tags', @@ -142,6 +152,8 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L152 # The directory where the git gem will be installed. def install_dir # :nodoc: + return unless File.exist? repo_cache_dir + File.join base_dir, 'gems', "#{@name}-#{dir_shortref}" end @@ -177,6 +189,8 @@ class Gem::Source::Git < Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source/git.rb#L189 def specs checkout + return [] unless install_dir + Dir.chdir install_dir do Dir['{,*,*/*}.gemspec'].map do |spec_file| directory = File.dirname spec_file Index: lib/rubygems/request.rb =================================================================== --- lib/rubygems/request.rb (revision 44798) +++ lib/rubygems/request.rb (revision 44799) @@ -48,15 +48,14 @@ class Gem::Request https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request.rb#L48 connection.key = OpenSSL::PKey::RSA.new pem end + store.set_default_paths + add_rubygems_trusted_certs(store) if Gem.configuration.ssl_ca_cert if File.directory? Gem.configuration.ssl_ca_cert store.add_path Gem.configuration.ssl_ca_cert else store.add_file Gem.configuration.ssl_ca_cert end - else - store.set_default_paths - add_rubygems_trusted_certs(store) end connection.cert_store = store rescue LoadError => e @@ -106,7 +105,8 @@ class Gem::Request https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request.rb#L105 request = @request_class.new @uri.request_uri unless @uri.nil? || @uri.user.nil? || @uri.user.empty? then - request.basic_auth @uri.user, @uri.password + request.basic_auth Gem::UriFormatter.new(@uri.user).unescape, + Gem::UriFormatter.new(@uri.password).unescape end request.add_field 'User-Agent', @user_agent Index: lib/rubygems/version.rb =================================================================== --- lib/rubygems/version.rb (revision 44798) +++ lib/rubygems/version.rb (revision 44799) @@ -22,6 +22,11 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L22 # 3. 1.0.a.2 # 4. 0.9 # +# If you want to specify a version restriction that includes both prereleases +# and regular releases of the 1.x series this is the best way: +# +# s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0' +# # == How Software Changes # # Users expect to be able to specify a version constraint that gives them Index: lib/rubygems/remote_fetcher.rb =================================================================== --- lib/rubygems/remote_fetcher.rb (revision 44798) +++ lib/rubygems/remote_fetcher.rb (revision 44799) @@ -131,11 +131,19 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L131 FileUtils.mkdir_p cache_dir rescue nil unless File.exist? cache_dir - # Always escape URI's to deal with potential spaces and such - unless URI::Generic === source_uri - source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ? - URI::DEFAULT_PARSER.escape(source_uri.to_s) : - URI.escape(source_uri.to_s)) + # Always escape URI's to deal with potential spaces and such + # It should also be considered that source_uri may already be + # a valid URI with escaped characters. e.g. "{DESede}" is encoded + # as "%7BDESede%7D". If this is escaped again the percentage + # symbols will be escaped. + unless source_uri.is_a?(URI::Generic) + begin + source_uri = URI.parse(source_uri) + rescue + source_uri = URI.parse(URI.const_defined?(:DEFAULT_PARSER) ? + URI::DEFAULT_PARSER.escape(source_uri.to_s) : + URI.escape(source_uri.to_s)) + end end scheme = source_uri.scheme @@ -285,20 +293,20 @@ class Gem::RemoteFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/remote_fetcher.rb#L293 def cache_update_path uri, path = nil, update = true mtime = path && File.stat(path).mtime rescue nil - if mtime && Net::HTTPNotModified === fetch_path(uri, mtime, true) - Gem.read_binary(path) - else - data = fetch_path(uri) + data = fetch_path(uri, mtime) - if update and path then - open(path, 'wb') do |io| - io.flock(File::LOCK_EX) - io.write data - end - end + if data == nil # indicates the server returned 304 Not Modified + return Gem.read_binary(path) + end - data + if update and path + open(path, 'wb') do |io| + io.flock(File::LOCK_EX) + io.write data + end end + + data end ## Index: lib/rubygems/installer.rb =================================================================== --- lib/rubygems/installer.rb (revision 44798) +++ lib/rubygems/installer.rb (revision 44799) @@ -641,7 +641,7 @@ version = "#{Gem::Requirement.default}" https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L641 if ARGV.first str = ARGV.first str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding - if str =~ /\\A_(.*)_\\z/ + if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then version = $1 ARGV.shift end Index: lib/rubygems/resolver/index_set.rb =================================================================== --- lib/rubygems/resolver/index_set.rb (revision 44798) +++ lib/rubygems/resolver/index_set.rb (revision 44799) @@ -5,6 +5,8 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/index_set.rb#L5 class Gem::Resolver::IndexSet < Gem::Resolver::Set def initialize source = nil # :nodoc: + super() + @f = if source then sources = Gem::SourceList.from [source] @@ -34,6 +36,8 @@ class Gem::Resolver::IndexSet < Gem::Res https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/index_set.rb#L36 def find_all req res = [] + return res unless @remote + name = req.dependency.name @all[name].each do |uri, n| Index: lib/rubygems/resolver/api_set.rb =================================================================== --- lib/rubygems/resolver/api_set.rb (revision 44798) +++ lib/rubygems/resolver/api_set.rb (revision 44799) @@ -25,10 +25,12 @@ class Gem::Resolver::APISet < Gem::Resol https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/api_set.rb#L25 # http://guides.rubygems.org/rubygems-org-api def initialize dep_uri = 'https://rubygems.org/api/v1/dependencies' + super() + dep_uri = URI dep_uri unless URI === dep_uri # for ruby 1.8 @dep_uri = dep_uri - @uri = dep_uri + '../../..' + @uri = dep_uri + '../..' @data = Hash.new { |h,k| h[k] = [] } @source = Gem::Source.new @uri @@ -41,6 +43,8 @@ class Gem::Resolver::APISet < Gem::Resol https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/api_set.rb#L43 def find_all req res = [] + return res unless @remote + versions(req.name).each do |ver| if req.dependency.match? req.name, ver[:number] res << Gem::Resolver::APISpecification.new(self, ver) @@ -55,6 +59,7 @@ class Gem::Resolver::APISet < Gem::Resol https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/api_set.rb#L59 # data for DependencyRequests +reqs+. def prefetch reqs + return unless @remote names = reqs.map { |r| r.dependency.name } needed = names - @data.keys Index: lib/rubygems/resolver/composed_set.rb =================================================================== --- lib/rubygems/resolver/composed_set.rb (revision 44798) +++ lib/rubygems/resolver/composed_set.rb (revision 44799) @@ -16,10 +16,21 @@ class Gem::Resolver::ComposedSet < Gem:: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/composed_set.rb#L16 # Gem::Resolver::compose_sets instead. def initialize *sets + super() + @sets = sets end ## + # Sets the remote network access for all composed sets. + + def remote= remote + super + + @sets.each { |set| set.remote = remote } + end + + ## # Finds all specs matching +req+ in all sets. def find_all req Index: lib/rubygems/resolver/set.rb =================================================================== --- lib/rubygems/resolver/set.rb (revision 44798) +++ lib/rubygems/resolver/set.rb (revision 44799) @@ -5,6 +5,15 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/set.rb#L5 class Gem::Resolver::Set ## + # Set to true to disable network access for this set + + attr_accessor :remote + + def initialize # :nodoc: + @remote = true + end + + ## # The find_all method must be implemented. It returns all Resolver # Specification objects matching the given DependencyRequest +req+. @@ -23,5 +32,13 @@ class Gem::Resolver::Set https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/set.rb#L32 def prefetch reqs end + ## + # When true, this set is allowed to access the network when looking up + # specifications or dependencies. + + def remote? # :nodoc: + @remote + end + end Index: lib/rubygems/resolver/git_set.rb =================================================================== --- lib/rubygems/resolver/git_set.rb (revision 44798) +++ lib/rubygems/resolver/git_set.rb (revision 44799) @@ -33,6 +33,8 @@ class Gem::Resolver::GitSet < Gem::Resol https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/git_set.rb#L33 attr_reader :specs # :nodoc: def initialize # :nodoc: + super() + @git = ENV['git'] || 'git' @need_submodules = {} @repositories = {} @@ -91,6 +93,7 @@ class Gem::Resolver::GitSet < Gem::Resol https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/git_set.rb#L93 @repositories.each do |name, (repository, reference)| source = Gem::Source::Git.new name, repository, reference source.root_dir = @root_dir + source.remote = @remote source.specs.each do |spec| git_spec = Gem::Resolver::GitSpecification.new self, spec, source Index: lib/rubygems/resolver/lock_set.rb =================================================================== --- lib/rubygems/resolver/lock_set.rb (revision 44798) +++ lib/rubygems/resolver/lock_set.rb (revision 44799) @@ -9,6 +9,8 @@ class Gem::Resolver::LockSet < Gem::Reso https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/lock_set.rb#L9 # Creates a new LockSet from the given +source+ def initialize source + super() + @source = Gem::Source::Lock.new source @specs = [] end Index: lib/rubygems/resolver/installer_set.rb =================================================================== --- lib/rubygems/resolver/installer_set.rb (revision 44798) +++ lib/rubygems/resolver/installer_set.rb (revision 44799) @@ -24,14 +24,17 @@ class Gem::Resolver::InstallerSet < Gem: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/installer_set.rb#L24 # Creates a new InstallerSet that will look for gems in +domain+. def initialize domain + super() + @domain = domain + @remote = consider_remote? @f = Gem::SpecFetcher.fetcher @always_install = [] @ignore_dependencies = false @ignore_installed = false - @remote_set = Gem::Resolver::BestSet.new if consider_remote? + @remote_set = Gem::Resolver::BestSet.new @specs = {} end @@ -120,5 +123,16 @@ class Gem::Resolver::InstallerSet < Gem: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/installer_set.rb#L123 end end + def remote= remote # :nodoc: + case @domain + when :local then + @domain = :both if remote + when :remote then + @domain = nil unless remote + when :both then + @domain = :local unless remote + end + end + end Index: lib/rubygems/resolver/best_set.rb =================================================================== --- lib/rubygems/resolver/best_set.rb (revision 44798) +++ lib/rubygems/resolver/best_set.rb (revision 44799) @@ -12,11 +12,30 @@ class Gem::Resolver::BestSet < Gem::Reso https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/best_set.rb#L12 def initialize sources = Gem.sources super() - sources.each_source do |source| + @sources = sources + end + + ## + # Picks which sets to use for the configured sources. + + def pick_sets # :nodoc: + @sources.each_source do |source| @sets << source.dependency_resolver_set end end + def find_all req # :nodoc: + pick_sets if @remote and @sets.empty? + + super + end + + def prefetch reqs # :nodoc: + pick_sets if @remote and @sets.empty? + + super + end + def pretty_print q # :nodoc: q.group 2, '[BestSet', ']' do q.breakable Index: lib/rubygems/resolver/vendor_set.rb =================================================================== --- lib/rubygems/resolver/vendor_set.rb (revision 44798) +++ lib/rubygems/resolver/vendor_set.rb (revision 44799) @@ -21,6 +21,8 @@ class Gem::Reso (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/