[前][次][番号順一覧][スレッド一覧]

ruby-changes:36649

From: drbrain <ko1@a...>
Date: Sun, 7 Dec 2014 09:53:25 +0900 (JST)
Subject: [ruby-changes:36649] drbrain:r48729 (trunk): * lib/rubygems: Update to RubyGems 2.4.5.

drbrain	2014-12-07 09:53:01 +0900 (Sun, 07 Dec 2014)

  New Revision: 48729

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48729

  Log:
    * lib/rubygems:  Update to RubyGems 2.4.5.
    * test/rubygems:  ditto.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/basic_specification.rb
    trunk/lib/rubygems/commands/pristine_command.rb
    trunk/lib/rubygems/commands/uninstall_command.rb
    trunk/lib/rubygems/core_ext/kernel_gem.rb
    trunk/lib/rubygems/core_ext/kernel_require.rb
    trunk/lib/rubygems/dependency_list.rb
    trunk/lib/rubygems/ext/ext_conf_builder.rb
    trunk/lib/rubygems/installer.rb
    trunk/lib/rubygems/package/tar_writer.rb
    trunk/lib/rubygems/request_set/lockfile.rb
    trunk/lib/rubygems/request_set.rb
    trunk/lib/rubygems/resolver/api_set.rb
    trunk/lib/rubygems/resolver/api_specification.rb
    trunk/lib/rubygems/resolver/installer_set.rb
    trunk/lib/rubygems/source.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/stub_specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/lib/rubygems/text.rb
    trunk/lib/rubygems.rb
    trunk/test/rubygems/test_gem.rb
    trunk/test/rubygems/test_gem_commands_pristine_command.rb
    trunk/test/rubygems/test_gem_package_tar_writer.rb
    trunk/test/rubygems/test_gem_request_set_lockfile.rb
    trunk/test/rubygems/test_gem_resolver_api_specification.rb
    trunk/test/rubygems/test_gem_resolver_installer_set.rb
    trunk/test/rubygems/test_gem_source.rb
    trunk/test/rubygems/test_gem_specification.rb
    trunk/test/rubygems/test_gem_stub_specification.rb
    trunk/test/rubygems/test_gem_text.rb
    trunk/test/rubygems/test_kernel.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48728)
+++ ChangeLog	(revision 48729)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Dec  7 09:52:30 2014  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems:  Update to RubyGems 2.4.5.
+	* test/rubygems:  ditto.
+
 Sat Dec  6 10:05:08 2014  Shugo Maeda  <shugo@r...>
 
 	* lib/net/imap.rb: Fix undefined variable usage & refactor/DRY
Index: lib/rubygems/basic_specification.rb
===================================================================
--- lib/rubygems/basic_specification.rb	(revision 48728)
+++ lib/rubygems/basic_specification.rb	(revision 48729)
@@ -58,23 +58,28 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L58
   # Return true if this spec can require +file+.
 
   def contains_requirable_file? file
-    if instance_variable_defined?(:@ignored) or
-       instance_variable_defined?('@ignored') then
-      return false
-    elsif missing_extensions? then
-      @ignored = true
-
-      warn "Ignoring #{full_name} because its extensions are not built.  " +
-           "Try: gem pristine #{full_name}"
-      return false
-    end
-
-    suffixes = Gem.suffixes
-
-    full_require_paths.any? do |dir|
-      base = "#{dir}/#{file}"
-      suffixes.any? { |suf| File.file? "#{base}#{suf}" }
-    end
+    @contains_requirable_file ||= {}
+    @contains_requirable_file[file] ||=
+    begin
+      if instance_variable_defined?(:@ignored) or
+         instance_variable_defined?('@ignored') then
+        return false
+      elsif missing_extensions? then
+        @ignored = true
+
+        warn "Ignoring #{full_name} because its extensions are not built.  " +
+             "Try: gem pristine #{name} --version #{version}"
+        return false
+      end
+
+      suffixes = Gem.suffixes
+
+      full_require_paths.any? do |dir|
+        base = "#{dir}/#{file}"
+        suffixes.any? { |suf| File.file? "#{base}#{suf}" }
+      end
+    end ? :yes : :no
+    @contains_requirable_file[file] == :yes
   end
 
   def default_gem?
@@ -134,13 +139,38 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L139
   # activated.
 
   def full_require_paths
-    full_paths = raw_require_paths.map do |path|
-      File.join full_gem_path, path
+    @full_require_paths ||=
+    begin
+      full_paths = raw_require_paths.map do |path|
+        File.join full_gem_path, path
+      end
+
+      full_paths.unshift extension_dir unless @extensions.nil? || @extensions.empty?
+
+      full_paths
     end
+  end
 
-    full_paths.unshift extension_dir unless @extensions.nil? || @extensions.empty?
+  ##
+  # Full path of the target library file.
+  # If the file is not in this gem, return nil.
 
-    full_paths
+  def to_fullpath path
+    if activated? then
+      @paths_map ||= {}
+      @paths_map[path] ||=
+      begin
+        fullpath = nil
+        suffixes = Gem.suffixes
+        full_require_paths.find do |dir|
+          suffixes.find do |suf|
+            File.file?(fullpath = "#{dir}/#{path}#{suf}")
+          end
+        end ? fullpath : nil
+      end
+    else
+      nil
+    end
   end
 
   ##
Index: lib/rubygems/ext/ext_conf_builder.rb
===================================================================
--- lib/rubygems/ext/ext_conf_builder.rb	(revision 48728)
+++ lib/rubygems/ext/ext_conf_builder.rb	(revision 48729)
@@ -49,7 +49,7 @@ class Gem::Ext::ExtConfBuilder < Gem::Ex https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/ext_conf_builder.rb#L49
             FileUtils.mkdir_p lib_dir
             entries = Dir.entries(tmp_dest) - %w[. ..]
             entries = entries.map { |entry| File.join tmp_dest, entry }
-            FileUtils.cp_r entries, lib_dir
+            FileUtils.cp_r entries, lib_dir, :remove_destination => true
           end
 
           FileEntry.new(tmp_dest).traverse do |ent|
Index: lib/rubygems/request_set.rb
===================================================================
--- lib/rubygems/request_set.rb	(revision 48728)
+++ lib/rubygems/request_set.rb	(revision 48729)
@@ -403,10 +403,7 @@ class Gem::RequestSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set.rb#L403
               "Unresolved dependency found during sorting - #{dep} (requested by #{node.spec.full_name})"
       end
 
-      begin
-        yield match
-      rescue TSort::Cyclic
-      end
+      yield match
     end
   end
 
Index: lib/rubygems/specification.rb
===================================================================
--- lib/rubygems/specification.rb	(revision 48728)
+++ lib/rubygems/specification.rb	(revision 48729)
@@ -709,8 +709,6 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L709
       specs = {}
       Gem.loaded_specs.each_value{|s| specs[s] = true}
       @@all.each{|s| s.activated = true if specs[s]}
-
-      _resort!(@@all)
     end
     @@all
   end
@@ -1479,6 +1477,16 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1477
   end
 
   ##
+  # Used to detect if the gem is bundled in older version of Ruby, but not
+  # detectable as default gem (see BasicSpecification#default_gem?).
+
+  def bundled_gem_in_old_ruby?
+    !default_gem? &&
+      RUBY_VERSION < "2.0.0" &&
+      summary == "This #{name} is bundled with Ruby"
+  end
+
+  ##
   # Returns the full path to the cache directory containing this
   # spec's cached gem.
 
Index: lib/rubygems/text.rb
===================================================================
--- lib/rubygems/text.rb	(revision 48728)
+++ lib/rubygems/text.rb	(revision 48729)
@@ -27,9 +27,9 @@ module Gem::Text https://github.com/ruby/ruby/blob/trunk/lib/rubygems/text.rb#L27
   end
 
   def min3 a, b, c # :nodoc:
-    if a < b && a < c
+    if a < b && a < c then
       a
-    elsif b < a && b < c
+    elsif b < c then
       b
     else
       c
Index: lib/rubygems/package/tar_writer.rb
===================================================================
--- lib/rubygems/package/tar_writer.rb	(revision 48728)
+++ lib/rubygems/package/tar_writer.rb	(revision 48729)
@@ -290,7 +290,9 @@ class Gem::Package::TarWriter https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package/tar_writer.rb#L290
   # Splits +name+ into a name and prefix that can fit in the TarHeader
 
   def split_name(name) # :nodoc:
-    raise Gem::Package::TooLongFileName if name.bytesize > 256
+    if name.bytesize > 256
+      raise Gem::Package::TooLongFileName.new("File \"#{name}\" has a too long path (should be 256 or less)") 
+    end
 
     if name.bytesize <= 100 then
       prefix = ""
@@ -308,8 +310,12 @@ class Gem::Package::TarWriter https://github.com/ruby/ruby/blob/trunk/lib/rubygems/package/tar_writer.rb#L310
       prefix = (parts + [nxt]).join "/"
       name = newname
 
-      if name.bytesize > 100 or prefix.bytesize > 155 then
-        raise Gem::Package::TooLongFileName
+      if name.bytesize > 100
+        raise Gem::Package::TooLongFileName.new("File \"#{prefix}/#{name}\" has a too long name (should be 100 or less)") 
+      end
+    
+      if prefix.bytesize > 155 then
+        raise Gem::Package::TooLongFileName.new("File \"#{prefix}/#{name}\" has a too long base path (should be 155 or less)") 
       end
     end
 
Index: lib/rubygems/commands/pristine_command.rb
===================================================================
--- lib/rubygems/commands/pristine_command.rb	(revision 48728)
+++ lib/rubygems/commands/pristine_command.rb	(revision 48729)
@@ -109,6 +109,11 @@ extensions will be restored. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L109
         next
       end
 
+      if spec.bundled_gem_in_old_ruby?
+        say "Skipped #{spec.full_name}, it is bundled with old Ruby"
+        next
+      end
+
       unless spec.extensions.empty? or options[:extensions] then
         say "Skipped #{spec.full_name}, it needs to compile an extension"
         next
@@ -120,8 +125,17 @@ extensions will be restored. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/pristine_command.rb#L125
         require 'rubygems/remote_fetcher'
 
         say "Cached gem for #{spec.full_name} not found, attempting to fetch..."
+
         dep = Gem::Dependency.new spec.name, spec.version
-        Gem::RemoteFetcher.fetcher.download_to_cache dep
+        found, _ = Gem::SpecFetcher.fetcher.spec_for_dependency dep
+
+        if found.empty?
+          say "Skipped #{spec.full_name}, it was not found from cache and remote sources"
+          next
+        end
+
+        spec_candidate, source = found.first
+        Gem::RemoteFetcher.fetcher.download spec_candidate, source.uri.to_s, spec.base_dir
       end
 
       env_shebang =
Index: lib/rubygems/commands/uninstall_command.rb
===================================================================
--- lib/rubygems/commands/uninstall_command.rb	(revision 48728)
+++ lib/rubygems/commands/uninstall_command.rb	(revision 48729)
@@ -124,7 +124,7 @@ that is a dependency of an existing gem. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/uninstall_command.rb#L124
   end
 
   def uninstall_all
-    _, specs = Gem::Specification.partition { |spec| spec.default_gem? }
+    specs = Gem::Specification.reject { |spec| spec.default_gem? }
 
     specs.each do |spec|
       options[:version] = spec.version
Index: lib/rubygems/stub_specification.rb
===================================================================
--- lib/rubygems/stub_specification.rb	(revision 48728)
+++ lib/rubygems/stub_specification.rb	(revision 48729)
@@ -42,6 +42,7 @@ class Gem::StubSpecification < Gem::Basi https://github.com/ruby/ruby/blob/trunk/lib/rubygems/stub_specification.rb#L42
     self.loaded_from = filename
     @data            = nil
     @extensions      = nil
+    @name            = nil
     @spec            = nil
   end
 
@@ -49,8 +50,11 @@ class Gem::StubSpecification < Gem::Basi https://github.com/ruby/ruby/blob/trunk/lib/rubygems/stub_specification.rb#L50
   # True when this gem has been activated
 
   def activated?
-    loaded = Gem.loaded_specs[name]
-    loaded && loaded.version == version
+    @activated ||=
+    begin
+      loaded = Gem.loaded_specs[name]
+      loaded && loaded.version == version
+    end
   end
 
   def build_extensions # :nodoc:
@@ -154,9 +158,11 @@ class Gem::StubSpecification < Gem::Basi https://github.com/ruby/ruby/blob/trunk/lib/rubygems/stub_specification.rb#L158
   # The full Gem::Specification for this gem, loaded from evalling its gemspec
 
   def to_spec
-    @spec ||= Gem.loaded_specs.values.find { |spec|
-      spec.name == @name and spec.version == @version
-    }
+    @spec ||= if @data then
+                Gem.loaded_specs.values.find { |spec|
+                  spec.name == name and spec.version == version
+                }
+              end
 
     @spec ||= Gem::Specification.load(loaded_from)
     @spec.ignored = @ignored if instance_variable_defined? :@ignored
Index: lib/rubygems/source.rb
===================================================================
--- lib/rubygems/source.rb	(revision 48728)
+++ lib/rubygems/source.rb	(revision 48729)
@@ -26,8 +26,12 @@ class Gem::Source https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source.rb#L26
   # Creates a new Source which will use the index located at +uri+.
 
   def initialize(uri)
-    unless uri.kind_of? URI
-      uri = URI.parse(uri.to_s)
+    begin
+      unless uri.kind_of? URI
+        uri = URI.parse(uri.to_s)
+      end
+    rescue URI::InvalidURIError
+      raise if Gem::Source == self.class
     end
 
     @uri = uri
Index: lib/rubygems/request_set/lockfile.rb
===================================================================
--- lib/rubygems/request_set/lockfile.rb	(revision 48728)
+++ lib/rubygems/request_set/lockfile.rb	(revision 48729)
@@ -200,6 +200,8 @@ class Gem::RequestSet::Lockfile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/lockfile.rb#L200
 
     platforms = @requests.map { |request| request.spec.platform }.uniq
 
+    platforms = platforms.sort_by { |platform| platform.to_s }
+
     platforms.sort.each do |platform|
       out << "  #{platform}"
     end
@@ -277,14 +279,7 @@ class Gem::RequestSet::Lockfile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/lockfile.rb#L279
       when :bang then
         get :bang
 
-        spec = @set.sets.select { |set|
-          Gem::Resolver::GitSet    === set or
-          Gem::Resolver::VendorSet === set
-        }.map { |set|
-          set.specs[name]
-        }.compact.first
-
-        requirements << spec.version
+        requirements << pinned_requirement(name)
       when :l_paren then
         get :l_paren
 
@@ -300,6 +295,13 @@ class Gem::RequestSet::Lockfile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/lockfile.rb#L295
         end
 
         get :r_paren
+
+        if peek[0] == :bang then
+          requirements.clear
+          requirements << pinned_requirement(name)
+
+          get :bang
+        end
       end
 
       @set.gem name, *requirements
@@ -507,6 +509,17 @@ class Gem::RequestSet::Lockfile https://github.com/ruby/ruby/blob/trunk/lib/rubygems/request_set/lockfile.rb#L509
     @tokens.first || [:EOF]
   end
 
+  def pinned_requirement name # :nodoc:
+    spec = @set.sets.select { |set|
+      Gem::Resolver::GitSet    === set or
+        Gem::Resolver::VendorSet === set
+    }.map { |set|
+      set.specs[name]
+    }.compact.first
+
+    spec.version
+  end
+
   def skip type # :nodoc:
     get while not @tokens.empty? and peek.first == type
   end
Index: lib/rubygems/core_ext/kernel_gem.rb
===================================================================
--- lib/rubygems/core_ext/kernel_gem.rb	(revision 48728)
+++ lib/rubygems/core_ext/kernel_gem.rb	(revision 48729)
@@ -55,7 +55,14 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/lib/rubygems/core_ext/kernel_gem.rb#L55
       gem_name = gem_name.name
     end
 
-    spec = Gem::Dependency.new(gem_name, *requirements).to_spec
+    dep = Gem::Dependency.new(gem_name, *requirements)
+
+    loaded = Gem.loaded_specs[gem_name]
+
+    return false if loaded && dep.matches_spec?(loaded)
+
+    spec = dep.to_spec
+
     Gem::LOADED_SPECS_MUTEX.synchronize {
       spec.activate
     } if spec
Index: lib/rubygems/core_ext/kernel_require.rb
===================================================================
--- lib/rubygems/core_ext/kernel_require.rb	(revision 48728)
+++ lib/rubygems/core_ext/kernel_require.rb	(revision 48729)
@@ -66,7 +66,7 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/lib/rubygems/core_ext/kernel_require.rb#L66
 
     begin
       RUBYGEMS_ACTIVATION_MONITOR.exit
-      return gem_original_require(path)
+      return gem_original_require(spec.to_fullpath(path) || path)
     end if spec
 
     # Attempt to find +path+ in any unresolved gems...
Index: lib/rubygems/installer.rb
===================================================================
--- lib/rubygems/installer.rb	(revision 48728)
+++ lib/rubygems/installer.rb	(revision 48729)
@@ -421,8 +421,8 @@ class Gem::Installer https://github.com/ruby/ruby/blob/trunk/lib/rubygems/installer.rb#L421
         next
       end
 
-      mode = File.stat(bin_path).mode | 0111
-      FileUtils.chmod mode, bin_path
+      mode = File.stat(bin_path).mode
+      FileUtils.chmod mode | 0111, bin_path unless (mode | 0111) == mode
 
       check_executable_overwrite filename
 
Index: lib/rubygems/resolver/api_set.rb
===================================================================
--- lib/rubygems/resolver/api_set.rb	(revision 48728)
+++ lib/rubygems/resolver/api_set.rb	(revision 48729)
@@ -72,7 +72,7 @@ class Gem::Resolver::APISet < Gem::Resol https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/api_set.rb#L72
     @to_fetch += needed
   end
 
-  def prefetch_now
+  def prefetch_now # :nodoc:
     needed, @to_fetch = @to_fetch, []
 
     uri = @dep_uri + "?gems=#{needed.sort.join ','}"
Index: lib/rubygems/resolver/installer_set.rb
===================================================================
--- lib/rubygems/resolver/installer_set.rb	(revision 48728)
+++ lib/rubygems/resolver/installer_set.rb	(revision 48729)
@@ -154,7 +154,7 @@ class Gem::Resolver::InstallerSet < Gem: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/installer_set.rb#L154
   end
 
   def prefetch(reqs)
-    @remote_set.prefetch(reqs)
+    @remote_set.prefetch(reqs) if consider_remote?
   end
 
   def prerelease= allow_prerelease
Index: lib/rubygems/resolver/api_specification.rb
===================================================================
--- lib/rubygems/resolver/api_specification.rb	(revision 48728)
+++ lib/rubygems/resolver/api_specification.rb	(revision 48729)
@@ -19,7 +19,7 @@ class Gem::Resolver::APISpecification < https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/api_specification.rb#L19
     @set = set
     @name = api_data[:name]
     @version = Gem::Version.new api_data[:number]
-    @platform = api_data[:platform]
+    @platform = Gem::Platform.new api_data[:platform]
     @dependencies = api_data[:dependencies].map do |name, ver|
       Gem::Dependency.new name, ver.split(/\s*,\s*/)
     end
Index: lib/rubygems/dependency_list.rb
===================================================================
--- lib/rubygems/dependency_list.rb	(revision 48728)
+++ lib/rubygems/dependency_list.rb	(revision 48729)
@@ -219,11 +219,7 @@ class Gem::DependencyList https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_list.rb#L219
     dependencies.each do |dep|
       specs.each do |spec|
         if spec.satisfies_requirement? dep then
-          begin
-            yield spec
-          rescue TSort::Cyclic
-            # do nothing
-          end
+          yield spec
           break
         end
       end
Index: lib/rubygems/test_case.rb
===================================================================
--- lib/rubygems/test_case.rb	(revision 48728)
+++ lib/rubygems/test_case.rb	(revision 48729)
@@ -1035,6 +1035,37 @@ Also, a list: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L1035
     Zlib::Deflate.deflate data
   end
 
+  def util_set_RUBY_VERSION(version, patchlevel = nil, revision = nil)
+    if Gem.instance_variables.include? :@ruby_version or
+       Gem.instance_variables.include? '@ruby_version' then
+      Gem.send :remove_instance_variable, :@ruby_version
+    end
+
+    @RUBY_VERSION    = RUBY_VERSION
+    @RUBY_PATCHLEVEL = RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
+    @RUBY_REVISION   = RUBY_REVISION   if defined?(RUBY_REVISION)
+
+    Object.send :remove_const, :RUBY_VERSION
+    Object.send :remove_const, :RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
+    Object.send :remove_const, :RUBY_REVISION   if defined?(RUBY_REVISION)
+
+    Object.const_set :RUBY_VERSION,    version
+    Object.const_set :RUBY_PATCHLEVEL, patchlevel if patchlevel
+    Object.const_set :RUBY_REVISION,   revision   if revision
+  end
+
+  def util_restore_RUBY_VERSION
+    Object.send :remove_const, :RUBY_VERSION
+    Object.send :remove_const, :RUBY_PATCHLEVEL if defined?(RUBY_PATCHLEVEL)
+    Object.send :remove_const, :RUBY_REVISION   if defined?(RUBY_REVISION)
+
+    Object.const_set :RUBY_VERSION,    @RUBY_VERSION
+    Object.const_set :RUBY_PATCHLEVEL, @RUBY_PATCHLEVEL if
+      defined?(@RUBY_PATCHLEVEL)
+    Object.const_set :RUBY_REVISION,   @RUBY_REVISION   if
+      defined?(@RUBY_REVISION)
+  end
+
   ##
   # Is this test being run on a Windows platform?
 
Index: lib/rubygems.rb
===================================================================
--- lib/rubygems.rb	(revision 48728)
+++ lib/rubygems.rb	(rev (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]