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

ruby-changes:41918

From: hsbt <ko1@a...>
Date: Fri, 4 Mar 2016 09:29:52 +0900 (JST)
Subject: [ruby-changes:41918] hsbt:r53992 (trunk): * lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.1.

hsbt	2016-03-04 09:29:40 +0900 (Fri, 04 Mar 2016)

  New Revision: 53992

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

  Log:
    * lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.1.
      Please see entries of 2.6.0 and 2.6.1 on
      https://github.com/rubygems/rubygems/blob/master/History.txt
      [fix GH-1270] Patch by @segiddins

  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/basic_specification.rb
    trunk/lib/rubygems/command.rb
    trunk/lib/rubygems/commands/cleanup_command.rb
    trunk/lib/rubygems/commands/install_command.rb
    trunk/lib/rubygems/commands/open_command.rb
    trunk/lib/rubygems/commands/push_command.rb
    trunk/lib/rubygems/commands/update_command.rb
    trunk/lib/rubygems/config_file.rb
    trunk/lib/rubygems/dependency.rb
    trunk/lib/rubygems/gemcutter_utilities.rb
    trunk/lib/rubygems/install_update_options.rb
    trunk/lib/rubygems/path_support.rb
    trunk/lib/rubygems/resolver/installer_set.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb
    trunk/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
    trunk/lib/rubygems/source_list.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/lib/rubygems/version.rb
    trunk/lib/rubygems.rb
    trunk/lib/ubygems.rb
    trunk/test/rubygems/test_gem.rb
    trunk/test/rubygems/test_gem_command.rb
    trunk/test/rubygems/test_gem_commands_cleanup_command.rb
    trunk/test/rubygems/test_gem_commands_install_command.rb
    trunk/test/rubygems/test_gem_commands_open_command.rb
    trunk/test/rubygems/test_gem_commands_push_command.rb
    trunk/test/rubygems/test_gem_ext_cmake_builder.rb
    trunk/test/rubygems/test_gem_gemcutter_utilities.rb
    trunk/test/rubygems/test_gem_path_support.rb
    trunk/test/rubygems/test_gem_source_list.rb
    trunk/test/rubygems/test_gem_version.rb
Index: lib/ubygems.rb
===================================================================
--- lib/ubygems.rb	(revision 53991)
+++ lib/ubygems.rb	(revision 53992)
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/lib/ubygems.rb#L1
-# frozen_string_literal: false
+# frozen_string_literal: true
 # This file allows for the running of rubygems with a nice
 # command line look-and-feel: ruby -rubygems foo.rb
 #--
Index: lib/rubygems/test_case.rb
===================================================================
--- lib/rubygems/test_case.rb	(revision 53991)
+++ lib/rubygems/test_case.rb	(revision 53992)
@@ -570,7 +570,7 @@ class Gem::TestCase < MiniTest::Unit::Te https://github.com/ruby/ruby/blob/trunk/lib/rubygems/test_case.rb#L570
   def write_file(path)
     path = File.join @gemhome, path unless Pathname.new(path).absolute?
     dir = File.dirname path
-    FileUtils.mkdir_p dir
+    FileUtils.mkdir_p dir unless File.directory? dir
 
     open path, 'wb' do |io|
       yield io if block_given?
Index: lib/rubygems/dependency.rb
===================================================================
--- lib/rubygems/dependency.rb	(revision 53991)
+++ lib/rubygems/dependency.rb	(revision 53992)
@@ -275,8 +275,9 @@ class Gem::Dependency https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency.rb#L275
   end
 
   def matching_specs platform_only = false
+    env_req = Gem.env_requirement(name)
     matches = Gem::Specification.stubs_for(name).find_all { |spec|
-      requirement.satisfied_by? spec.version
+      requirement.satisfied_by?(spec.version) && env_req.satisfied_by?(spec.version)
     }.map(&:to_spec)
 
     if platform_only
Index: lib/rubygems/basic_specification.rb
===================================================================
--- lib/rubygems/basic_specification.rb	(revision 53991)
+++ lib/rubygems/basic_specification.rb	(revision 53992)
@@ -95,7 +95,7 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L95
   # Returns path to the extensions directory.
 
   def extensions_dir
-    @extensions_dir ||= Gem.default_ext_dir_for(base_dir) ||
+    Gem.default_ext_dir_for(base_dir) ||
       File.join(base_dir, 'extensions', Gem::Platform.local.to_s,
                 Gem.extension_api_version)
   end
@@ -196,7 +196,6 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L196
 
   def internal_init # :nodoc:
     @extension_dir = nil
-    @extensions_dir = nil
     @full_gem_path         = nil
     @gem_dir               = nil
     @ignored = nil
Index: lib/rubygems/install_update_options.rb
===================================================================
--- lib/rubygems/install_update_options.rb	(revision 53991)
+++ lib/rubygems/install_update_options.rb	(revision 53992)
@@ -179,6 +179,7 @@ module Gem::InstallUpdateOptions https://github.com/ruby/ruby/blob/trunk/lib/rubygems/install_update_options.rb#L179
                 "Print post install message") do |value, options|
       options[:post_install_message] = value
     end
+
   end
 
   ##
Index: lib/rubygems/gemcutter_utilities.rb
===================================================================
--- lib/rubygems/gemcutter_utilities.rb	(revision 53991)
+++ lib/rubygems/gemcutter_utilities.rb	(revision 53992)
@@ -115,7 +115,7 @@ module Gem::GemcutterUtilities https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L115
 
     with_response response do |resp|
       say "Signed in."
-      Gem.configuration.rubygems_api_key = resp.body
+      set_api_key host, resp.body
     end
   end
 
@@ -156,5 +156,13 @@ module Gem::GemcutterUtilities https://github.com/ruby/ruby/blob/trunk/lib/rubygems/gemcutter_utilities.rb#L156
     end
   end
 
+  def set_api_key host, key
+    if host == Gem::DEFAULT_HOST
+      Gem.configuration.rubygems_api_key = key
+    else
+      Gem.configuration.set_api_key host, key
+    end
+  end
+
 end
 
Index: lib/rubygems/config_file.rb
===================================================================
--- lib/rubygems/config_file.rb	(revision 53991)
+++ lib/rubygems/config_file.rb	(revision 53992)
@@ -306,9 +306,18 @@ if you believe they were disclosed to a https://github.com/ruby/ruby/blob/trunk/lib/rubygems/config_file.rb#L306
   # Sets the RubyGems.org API key to +api_key+
 
   def rubygems_api_key= api_key
+    set_api_key :rubygems_api_key, api_key
+
+    @rubygems_api_key = api_key
+  end
+
+  ##
+  # Set a specific host's API key to +api_key+
+
+  def set_api_key host, api_key
     check_credentials_permissions
 
-    config = load_file(credentials_path).merge(:rubygems_api_key => api_key)
+    config = load_file(credentials_path).merge(host => api_key)
 
     dirname = File.dirname credentials_path
     Dir.mkdir(dirname) unless File.exist? dirname
@@ -320,7 +329,7 @@ if you believe they were disclosed to a https://github.com/ruby/ruby/blob/trunk/lib/rubygems/config_file.rb#L329
       f.write config.to_yaml
     end
 
-    @rubygems_api_key = api_key
+    load_api_keys # reload
   end
 
   def load_file(filename)
Index: lib/rubygems/specification.rb
===================================================================
--- lib/rubygems/specification.rb	(revision 53991)
+++ lib/rubygems/specification.rb	(revision 53992)
@@ -1684,6 +1684,8 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1684
         (conflicts[spec] ||= []) << dep
       end
     }
+    env_req = Gem.env_requirement(name)
+    (conflicts[self] ||= []) << env_req unless env_req.satisfied_by? version
     conflicts
   end
 
@@ -1701,6 +1703,7 @@ class Gem::Specification < Gem::BasicSpe https://github.com/ruby/ruby/blob/trunk/lib/rubygems/specification.rb#L1703
   # Return true if there are possible conflicts against the currently loaded specs.
 
   def has_conflicts?
+    return true unless Gem.env_requirement(name).satisfied_by?(version)
     self.dependencies.any? { |dep|
       if dep.runtime? then
         spec = Gem.loaded_specs[dep.name]
Index: lib/rubygems/commands/install_command.rb
===================================================================
--- lib/rubygems/commands/install_command.rb	(revision 53991)
+++ lib/rubygems/commands/install_command.rb	(revision 53992)
@@ -186,6 +186,7 @@ to write the specification by hand.  For https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/install_command.rb#L186
   end
 
   def execute
+
     if options.include? :gemdeps then
       install_from_gemdeps
       return # not reached
Index: lib/rubygems/commands/update_command.rb
===================================================================
--- lib/rubygems/commands/update_command.rb	(revision 53991)
+++ lib/rubygems/commands/update_command.rb	(revision 53992)
@@ -85,6 +85,7 @@ command to remove old versions. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/update_command.rb#L85
   end
 
   def execute
+
     if options[:system] then
       update_rubygems
       return
Index: lib/rubygems/commands/cleanup_command.rb
===================================================================
--- lib/rubygems/commands/cleanup_command.rb	(revision 53991)
+++ lib/rubygems/commands/cleanup_command.rb	(revision 53992)
@@ -76,6 +76,9 @@ If no gems are named all gems in GEM_HOM https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cleanup_command.rb#L76
   end
 
   def clean_gems
+    @original_home = Gem.dir
+    @original_path = Gem.path
+
     get_primary_gems
     get_candidate_gems
     get_gems_to_cleanup
@@ -87,9 +90,6 @@ If no gems are named all gems in GEM_HOM https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cleanup_command.rb#L90
 
     deps = deplist.strongly_connected_components.flatten
 
-    @original_home = Gem.dir
-    @original_path = Gem.path
-
     deps.reverse_each do |spec|
       uninstall_dep spec
     end
@@ -108,6 +108,7 @@ If no gems are named all gems in GEM_HOM https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cleanup_command.rb#L108
   end
 
   def get_gems_to_cleanup
+
     gems_to_cleanup = @candidate_gems.select { |spec|
       @primary_gems[spec.name].version != spec.version
     }
@@ -116,6 +117,10 @@ If no gems are named all gems in GEM_HOM https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/cleanup_command.rb#L117
       spec.default_gem?
     }
 
+    gems_to_cleanup = gems_to_cleanup.select { |spec|
+      spec.base_dir == @original_home
+    }
+
     @default_gems += default_gems
     @default_gems.uniq!
     @gems_to_cleanup = gems_to_cleanup.uniq
Index: lib/rubygems/commands/push_command.rb
===================================================================
--- lib/rubygems/commands/push_command.rb	(revision 53991)
+++ lib/rubygems/commands/push_command.rb	(revision 53992)
@@ -76,13 +76,17 @@ You can upgrade or downgrade to the late https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/push_command.rb#L76
       @host = gem_data.spec.metadata['default_gem_server']
     end
 
-    # Always include this, even if it's nil
-    args << @host
+    push_host = nil
 
     if gem_data.spec.metadata.has_key?('allowed_push_host')
-      args << gem_data.spec.metadata['allowed_push_host']
+      push_host = gem_data.spec.metadata['allowed_push_host']
     end
 
+    @host ||= push_host
+
+    # Always include @host, even if it's nil
+    args += [ @host, push_host ]
+
     say "Pushing gem to #{@host || Gem.host}..."
 
     response = rubygems_api_request(*args) do |request|
Index: lib/rubygems/commands/open_command.rb
===================================================================
--- lib/rubygems/commands/open_command.rb	(revision 53991)
+++ lib/rubygems/commands/open_command.rb	(revision 53992)
@@ -15,6 +15,10 @@ class Gem::Commands::OpenCommand < Gem:: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/open_command.rb#L15
                "Opens gem sources in EDITOR") do |editor, options|
       options[:editor] = editor || get_env_editor
     end
+    add_option('-v', '--version VERSION', String,
+               "Opens specific gem version") do |version|
+      options[:version]  = version
+    end
   end
 
   def arguments # :nodoc:
Index: lib/rubygems/command.rb
===================================================================
--- lib/rubygems/command.rb	(revision 53991)
+++ lib/rubygems/command.rb	(revision 53992)
@@ -300,6 +300,8 @@ class Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command.rb#L300
 
     options[:build_args] = build_args
 
+    self.ui = Gem::SilentUI.new if options[:silent]
+
     if options[:help] then
       show_help
     elsif @when_invoked then
@@ -520,10 +522,15 @@ class Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/command.rb#L522
     end
   end
 
-  add_common_option('-q', '--quiet', 'Silence commands') do |value, options|
+  add_common_option('-q', '--quiet', 'Silence command progress meter') do |value, options|
     Gem.configuration.verbose = false
   end
 
+  add_common_option("--silent",
+                    "Silence rubygems output") do |value, options|
+    options[:silent] = true
+  end
+
   # Backtrace and config-file are added so they show up in the help
   # commands.  Both options are actually handled before the other
   # options get parsed.
Index: lib/rubygems/path_support.rb
===================================================================
--- lib/rubygems/path_support.rb	(revision 53991)
+++ lib/rubygems/path_support.rb	(revision 53992)
@@ -22,21 +22,16 @@ class Gem::PathSupport https://github.com/ruby/ruby/blob/trunk/lib/rubygems/path_support.rb#L22
   # Constructor. Takes a single argument which is to be treated like a
   # hashtable, or defaults to ENV, the system environment.
   #
-  def initialize(env=ENV)
-    @env = env
-
-    # note 'env' vs 'ENV'...
-    @home     = env["GEM_HOME"] || ENV["GEM_HOME"] || Gem.default_dir
+  def initialize(env)
+    @home     = env["GEM_HOME"] || Gem.default_dir
 
     if File::ALT_SEPARATOR then
       @home   = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR)
     end
 
-    self.path = env["GEM_PATH"] || ENV["GEM_PATH"]
+    @path = split_gem_path env["GEM_PATH"], @home
 
-    @spec_cache_dir =
-      env["GEM_SPEC_CACHE"] || ENV["GEM_SPEC_CACHE"] ||
-        Gem.default_spec_cache_dir
+    @spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir
 
     @spec_cache_dir = @spec_cache_dir.dup.untaint
   end
@@ -44,24 +39,19 @@ class Gem::PathSupport https://github.com/ruby/ruby/blob/trunk/lib/rubygems/path_support.rb#L39
   private
 
   ##
-  # Set the Gem search path (as reported by Gem.path).
+  # Split the Gem search path (as reported by Gem.path).
 
-  def path=(gpaths)
+  def split_gem_path gpaths, home
     # FIX: it should be [home, *path], not [*path, home]
 
     gem_path = []
 
-    # FIX: I can't tell wtf this is doing.
-    gpaths ||= (ENV['GEM_PATH'] || "").empty? ? nil : ENV["GEM_PATH"]
-
     if gpaths
-      if gpaths.kind_of?(Array)
-        gem_path = gpaths.dup
-      else
-        gem_path = gpaths.split(Gem.path_separator)
-        if gpaths.end_with?(Gem.path_separator)
-          gem_path += default_path
-        end
+      gem_path = gpaths.split(Gem.path_separator)
+      # Handle the path_separator being set to a regexp, which will cause
+      # end_with? to error
+      if gpaths =~ /#{Gem.path_separator}\z/
+        gem_path += default_path
       end
 
       if File::ALT_SEPARATOR then
@@ -70,12 +60,12 @@ class Gem::PathSupport https://github.com/ruby/ruby/blob/trunk/lib/rubygems/path_support.rb#L60
         end
       end
 
-      gem_path << @home
+      gem_path << home
     else
       gem_path = default_path
     end
 
-    @path = gem_path.uniq
+    gem_path.uniq
   end
 
   # Return the default Gem path
Index: lib/rubygems/source_list.rb
===================================================================
--- lib/rubygems/source_list.rb	(revision 53991)
+++ lib/rubygems/source_list.rb	(revision 53992)
@@ -59,7 +59,7 @@ class Gem::SourceList https://github.com/ruby/ruby/blob/trunk/lib/rubygems/source_list.rb#L59
             Gem::Source.new(URI.parse(obj))
           end
 
-    @sources << src
+    @sources << src unless @sources.include?(src)
     src
   end
 
Index: lib/rubygems/version.rb
===================================================================
--- lib/rubygems/version.rb	(revision 53991)
+++ lib/rubygems/version.rb	(revision 53992)
@@ -219,7 +219,7 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L219
 
   def bump
     @bump ||= begin
-                segments = self.segments.dup
+                segments = self.segments
                 segments.pop while segments.any? { |s| String === s }
                 segments.pop if segments.size > 1
 
@@ -298,7 +298,7 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L298
 
   def release
     @release ||= if prerelease?
-                   segments = self.segments.dup
+                   segments = self.segments
                    segments.pop while segments.any? { |s| String === s }
                    self.class.new segments.join('.')
                  else
@@ -307,20 +307,14 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L307
   end
 
   def segments # :nodoc:
-
-    # segments is lazy so it can pick up version values that come from
-    # old marshaled versions, which don't go through marshal_load.
-
-    @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
-      /^\d+$/ =~ s ? s.to_i : s
-    end
+    _segments.dup
   end
 
   ##
   # A recommended version for use with a ~> Requirement.
 
   def approximate_recommendation
-    segments = self.segments.dup
+    segments = self.segments
 
     segments.pop    while segments.any? { |s| String === s }
     segments.pop    while segments.size > 2
@@ -339,8 +333,8 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L333
     return unless Gem::Version === other
     return 0 if @version == other._version
 
-    lhsegments = segments
-    rhsegments = other.segments
+    lhsegments = _segments
+    rhsegments = other._segments
 
     lhsize = lhsegments.size
     rhsize = rhsegments.size
@@ -367,4 +361,14 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/lib/rubygems/version.rb#L361
   def _version
     @version
   end
+
+  def _segments
+    # segments is lazy so it can pick up version values that come from
+    # old marshaled versions, which don't go through marshal_load.
+    # since this version object is cached in @@all, its @segments should be frozen
+
+    @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
+      /^\d+$/ =~ s ? s.to_i : s
+    end.freeze
+  end
 end
Index: lib/rubygems/resolver/installer_set.rb
===================================================================
--- lib/rubygems/resolver/installer_set.rb	(revision 53991)
+++ lib/rubygems/resolver/installer_set.rb	(revision 53992)
@@ -138,10 +138,14 @@ class Gem::Resolver::InstallerSet < Gem: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/installer_set.rb#L138
 
       local_source = Gem::Source::Local.new
 
-      if local_spec = local_source.find_gem(name, dep.requirement) then
-        res << Gem::Resolver::IndexSpecification.new(
-          self, local_spec.name, local_spec.version,
-          local_source, local_spec.platform)
+      begin
+        if local_spec = local_source.find_gem(name, dep.requirement) then
+          res << Gem::Resolver::IndexSpecification.new(
+            self, local_spec.name, local_spec.version,
+            local_source, local_spec.platform)
+        end
+      rescue Gem::Package::FormatError
+        # ignore
       end
     end
 
Index: lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
===================================================================
--- lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb	(revision 53991)
+++ lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb	(revision 53992)
@@ -127,6 +127,10 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb#L127
         v.incoming_edges.delete(e)
         detach_vertex_named(v.name) unless v.root? || v.predecessors.any?
       end
+      vertex.incoming_edges.each do |e|
+        v = e.origin
+        v.outgoing_edges.delete(e)
+      end
     end
 
     # @param [String] name
Index: lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
===================================================================
--- lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb	(revision 53991)
+++ lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb	(revision 53992)
@@ -342,26 +342,37 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb#L342
       # @return [Boolean] Whether the possibility was swapped into {#activated}
       def attempt_to_swap_possibility
         swapped = activated.dup
-        swapped.vertex_named(name).payload = possibility
-        return unless swapped.vertex_named(name).requirements.
+        vertex = swapped.vertex_named(name)
+        vertex.payload = possibility
+        return unless vertex.requirements.
             all? { |r| requirement_satisfied_by?(r, swapped, possibility) }
-        attempt_to_activate_new_spec
+        return unless new_spec_satisfied?
+        actual_vertex = activated.vertex_named(name)
+        actual_vertex.payload = possibility
+        fixup_swapped_children(actual_vertex)
+        activate_spec
+      end
+
+      # Ensures there are no orphaned successors to the given {vertex}.
+      # @param [DependencyGraph::Vertex] vertex the ve (... truncated)

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

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