ruby-changes:45879
From: naruse <ko1@a...>
Date: Mon, 13 Mar 2017 15:58:26 +0900 (JST)
Subject: [ruby-changes:45879] naruse:r57952 (ruby_2_4): merge revision(s) 57412: [Backport #13308]
naruse 2017-03-13 15:58:19 +0900 (Mon, 13 Mar 2017) New Revision: 57952 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57952 Log: merge revision(s) 57412: [Backport #13308] Update Rubygems 2.6.10 * https://github.com/rubygems/rubygems/commit/2ee5bf9fd3bd7649d3e244bc40107ff32070ef47 * https://github.com/rubygems/rubygems/commit/be510dd4097e65c6a256a6e173d6b724a3a96472 Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/lib/rubygems/commands/setup_command.rb branches/ruby_2_4/lib/rubygems/core_ext/kernel_require.rb branches/ruby_2_4/lib/rubygems/ext/ext_conf_builder.rb branches/ruby_2_4/lib/rubygems/ext/rake_builder.rb branches/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb branches/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb branches/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb branches/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb branches/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb branches/ruby_2_4/lib/rubygems/server.rb branches/ruby_2_4/lib/rubygems/stub_specification.rb branches/ruby_2_4/lib/rubygems/version.rb branches/ruby_2_4/lib/rubygems.rb branches/ruby_2_4/test/rubygems/test_gem.rb branches/ruby_2_4/test/rubygems/test_gem_ext_ext_conf_builder.rb branches/ruby_2_4/test/rubygems/test_gem_ext_rake_builder.rb branches/ruby_2_4/test/rubygems/test_gem_remote_fetcher.rb branches/ruby_2_4/test/rubygems/test_gem_server.rb branches/ruby_2_4/test/rubygems/test_gem_specification.rb branches/ruby_2_4/test/rubygems/test_gem_stub_specification.rb branches/ruby_2_4/test/rubygems/test_gem_version.rb branches/ruby_2_4/test/rubygems/test_require.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 57951) +++ ruby_2_4/version.h (revision 57952) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.0" #define RUBY_RELEASE_DATE "2017-03-13" -#define RUBY_PATCHLEVEL 97 +#define RUBY_PATCHLEVEL 98 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 3 Index: ruby_2_4/lib/rubygems.rb =================================================================== --- ruby_2_4/lib/rubygems.rb (revision 57951) +++ ruby_2_4/lib/rubygems.rb (revision 57952) @@ -10,7 +10,7 @@ require 'rbconfig' https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems.rb#L10 require 'thread' module Gem - VERSION = '2.6.8' + VERSION = "2.6.10" end # Must be first since it unloads the prelude from 1.9.2 Index: ruby_2_4/lib/rubygems/version.rb =================================================================== --- ruby_2_4/lib/rubygems/version.rb (revision 57951) +++ ruby_2_4/lib/rubygems/version.rb (revision 57952) @@ -204,8 +204,12 @@ class Gem::Version https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/version.rb#L204 # series of digits or ASCII letters separated by dots. def initialize version - raise ArgumentError, "Malformed version number string #{version}" unless - self.class.correct?(version) + unless self.class.correct?(version) + raise ArgumentError, "Malformed version number string #{version}" + end + + # If version is an empty string convert it to 0 + version = 0 if version =~ /\A\s*\Z/ @version = version.to_s.strip.gsub("-",".pre.") @segments = nil Index: ruby_2_4/lib/rubygems/commands/setup_command.rb =================================================================== --- ruby_2_4/lib/rubygems/commands/setup_command.rb (revision 57951) +++ ruby_2_4/lib/rubygems/commands/setup_command.rb (revision 57952) @@ -47,7 +47,7 @@ class Gem::Commands::SetupCommand < Gem: https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/commands/setup_command.rb#L47 end add_option '--[no-]document [TYPES]', Array, - 'Generate documentation for RubyGems.', + 'Generate documentation for RubyGems', 'List the documentation types you wish to', 'generate. For example: rdoc,ri' do |value, options| options[:document] = case value Index: ruby_2_4/lib/rubygems/server.rb =================================================================== --- ruby_2_4/lib/rubygems/server.rb (revision 57951) +++ ruby_2_4/lib/rubygems/server.rb (revision 57952) @@ -2,6 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/server.rb#L2 require 'webrick' require 'zlib' require 'erb' +require 'uri' require 'rubygems' require 'rubygems/rdoc' @@ -68,7 +69,7 @@ class Gem::Server https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/server.rb#L69 <h1>Summary</h1> <p>There are <%=values["gem_count"]%> gems installed:</p> <p> - <%= values["specs"].map { |v| "<a href\"##{u v["name"]}\">#{h v["name"]}</a>" }.join ', ' %>. + <%= values["specs"].map { |v| "<a href=\"##{u v["name"]}\">#{h v["name"]}</a>" }.join ', ' %>. <h1>Gems</h1> <dl> @@ -81,20 +82,20 @@ class Gem::Server https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/server.rb#L82 <b><%=h spec["name"]%> <%=h spec["version"]%></b> <% if spec["ri_installed"] || spec["rdoc_installed"] then %> - <a href="<%=u spec["doc_path"]%>">[rdoc]</a> + <a href="<%=spec["doc_path"]%>">[rdoc]</a> <% else %> <span title="rdoc not installed">[rdoc]</span> <% end %> <% if spec["homepage"] then %> - <a href="<%=u spec["homepage"]%>" title="<%=h spec["homepage"]%>">[www]</a> + <a href="<%=uri_encode spec["homepage"]%>" title="<%=h spec["homepage"]%>">[www]</a> <% else %> <span title="no homepage available">[www]</span> <% end %> <% if spec["has_deps"] then %> - depends on - <%= spec["dependencies"].map { |v| "<a href=\"##{u v["name"]}>#{h v["name"]}</a>" }.join ', ' %>. + <%= spec["dependencies"].map { |v| "<a href=\"##{u v["name"]}\">#{h v["name"]}</a>" }.join ', ' %>. <% end %> </dt> <dd> @@ -455,6 +456,12 @@ div.method-source-code pre { color: #ffd https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/server.rb#L456 end.max end + def uri_encode(str) + str.gsub(URI::UNSAFE) do |match| + match.each_byte.map { |c| sprintf('%%%02X', c.ord) }.join + end + end + def doc_root gem_name if have_rdoc_4_plus? then "/doc_root/#{u gem_name}/" Index: ruby_2_4/lib/rubygems/core_ext/kernel_require.rb =================================================================== --- ruby_2_4/lib/rubygems/core_ext/kernel_require.rb (revision 57951) +++ ruby_2_4/lib/rubygems/core_ext/kernel_require.rb (revision 57952) @@ -44,7 +44,7 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/core_ext/kernel_require.rb#L44 spec = Gem.find_unresolved_default_spec(path) if spec Gem.remove_unresolved_default_spec(spec) - gem(spec.name) + Kernel.send(:gem, spec.name) end # If there are no unresolved deps, then we can use just try Index: ruby_2_4/lib/rubygems/stub_specification.rb =================================================================== --- ruby_2_4/lib/rubygems/stub_specification.rb (revision 57951) +++ ruby_2_4/lib/rubygems/stub_specification.rb (revision 57952) @@ -39,7 +39,12 @@ class Gem::StubSpecification < Gem::Basi https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/stub_specification.rb#L39 def initialize data, extensions parts = data[PREFIX.length..-1].split(" ".freeze, 4) @name = parts[0].freeze - @version = Gem::Version.new parts[1] + @version = if Gem::Version.correct?(parts[1]) + Gem::Version.new(parts[1]) + else + Gem::Version.new(0) + end + @platform = Gem::Platform.new parts[2] @extensions = extensions @full_name = if platform == Gem::Platform::RUBY Index: ruby_2_4/lib/rubygems/ext/rake_builder.rb =================================================================== --- ruby_2_4/lib/rubygems/ext/rake_builder.rb (revision 57951) +++ ruby_2_4/lib/rubygems/ext/rake_builder.rb (revision 57952) @@ -9,7 +9,7 @@ class Gem::Ext::RakeBuilder < Gem::Ext:: https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/ext/rake_builder.rb#L9 def self.build(extension, directory, dest_path, results, args=[], lib_dir=nil) if File.basename(extension) =~ /mkrf_conf/i then - cmd = "#{Gem.ruby} #{File.basename extension}" + cmd = "#{Gem.ruby} #{File.basename extension}".dup cmd << " #{args.join " "}" unless args.empty? run cmd, results end Index: ruby_2_4/lib/rubygems/ext/ext_conf_builder.rb =================================================================== --- ruby_2_4/lib/rubygems/ext/ext_conf_builder.rb (revision 57951) +++ ruby_2_4/lib/rubygems/ext/ext_conf_builder.rb (revision 57952) @@ -48,9 +48,11 @@ class Gem::Ext::ExtConfBuilder < Gem::Ex https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/ext/ext_conf_builder.rb#L48 run cmd, results ensure if File.exist? 'mkmf.log' - results << "To see why this extension failed to compile, please check" \ - " the mkmf.log which can be found here:\n" - results << " " + File.join(dest_path, 'mkmf.log') + "\n" + unless $?.success? then + results << "To see why this extension failed to compile, please check" \ + " the mkmf.log which can be found here:\n" + results << " " + File.join(dest_path, 'mkmf.log') + "\n" + end FileUtils.mv 'mkmf.log', dest_path end siteconf.unlink Index: ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb =================================================================== --- ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb (revision 57951) +++ ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb (revision 57952) @@ -194,18 +194,20 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb#L194 def state_index_for_unwind current_requirement = requirement existing_requirement = requirement_for_existing_name(name) - until current_requirement.nil? - current_state = find_state_for(current_requirement) - return states.index(current_state) if state_any?(current_state) - current_requirement = parent_of(current_requirement) + index = -1 + [current_requirement, existing_requirement].each do |r| + until r.nil? + current_state = find_state_for(r) + if state_any?(current_state) + current_index = states.index(current_state) + index = current_index if current_index > index + break + end + r = parent_of(r) + end end - until existing_requirement.nil? - existing_state = find_state_for(existing_requirement) - return states.index(existing_state) if state_any?(existing_state) - existing_requirement = parent_of(existing_requirement) - end - -1 + index end # @return [Object] the requirement that led to `requirement` being added @@ -364,19 +366,17 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb#L366 if matching_deps.empty? && !succ.root? && succ.predecessors.to_a == [vertex] debug(depth) { "Removing orphaned spec #{succ.name} after swapping #{name}" } succ.requirements.each { |r| @parent_of.delete(r) } - activated.detach_vertex_named(succ.name) - - all_successor_names = succ.recursive_successors.map(&:name) - requirements.delete_if do |requirement| - requirement_name = name_for(requirement) - (requirement_name == succ.name) || all_successor_names.include?(requirement_name) + removed_names = activated.detach_vertex_named(succ.name).map(&:name) + requirements.delete_if do |r| + # the only removed vertices are those with no other requirements, + # so it's safe to delete only based upon name here + removed_names.include?(name_for(r)) end elsif !matching_deps.include?(outgoing_edge.requirement) activated.delete_edge(outgoing_edge) requirements.delete(outgoing_edge.requirement) end - matching_deps.delete(outgoing_edge.requirement) end end Index: ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb =================================================================== --- ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb (revision 57951) +++ ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb (revision 57952) @@ -1,5 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb#L1 # frozen_string_literal: true module Gem::Resolver::Molinillo # The version of Gem::Resolver::Molinillo. - VERSION = '0.5.3'.freeze + VERSION = '0.5.5'.freeze end Index: ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb =================================================================== --- ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb (revision 57951) +++ ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb (revision 57952) @@ -14,16 +14,23 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb#L14 # (see Action#up) def up(graph) - return unless @vertex = graph.vertices.delete(name) + return [] unless @vertex = graph.vertices.delete(name) + + removed_vertices = [@vertex] @vertex.outgoing_edges.each do |e| v = e.destination v.incoming_edges.delete(e) - graph.detach_vertex_named(v.name) unless v.root? || v.predecessors.any? + if !v.root? && v.incoming_edges.empty? + removed_vertices.concat graph.detach_vertex_named(v.name) + end end + @vertex.incoming_edges.each do |e| v = e.origin v.outgoing_edges.delete(e) end + + removed_vertices end # (see Action#down) Index: ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb =================================================================== --- ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb (revision 57951) +++ ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb (revision 57952) @@ -81,6 +81,7 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb#L81 # @return [Boolean] whether the two vertices are equal, determined # by a recursive traversal of each {Vertex#successors} def ==(other) + return true if equal?(other) shallow_eql?(other) && successors.to_set == other.successors.to_set end @@ -89,6 +90,7 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb#L90 # @return [Boolean] whether the two vertices are equal, determined # solely by {#name} and {#payload} equality def shallow_eql?(other) + return true if equal?(other) other && name == other.name && payload == other.payload Index: ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb =================================================================== --- ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb (revision 57951) +++ ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb (revision 57952) @@ -119,6 +119,7 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb#L119 # {Vertex#successors} def ==(other) return false unless other + return true if equal?(other) vertices.each do |name, vertex| other_vertex = other.vertex_named(name) return false unless other_vertex @@ -134,6 +135,7 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb#L135 def add_child_vertex(name, payload, parent_names, requirement) root = !parent_names.delete(nil) { true } vertex = add_vertex(name, payload, root) + vertex.explicit_requirements << requirement if root parent_names.each do |parent_name| parent_node = vertex_named(parent_name) add_edge(parent_node, vertex, requirement) @@ -152,7 +154,7 @@ module Gem::Resolver::Molinillo https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb#L154 # Detaches the {#vertex_named} `name` {Vertex} from the graph, recursively # removing any non-root vertices that were orphaned in the process # @param [String] name - # @return [void] + # @return [Array<Vertex>] the vertices which have been detached def detach_vertex_named(name) log.detach_vertex_named(self, name) end Index: ruby_2_4/test/rubygems/test_gem_stub_specification.rb =================================================================== --- ruby_2_4/test/rubygems/test_gem_stub_specification.rb (revision 57951) +++ ruby_2_4/test/rubygems/test_gem_stub_specification.rb (revision 57952) @@ -33,6 +33,20 @@ class TestStubSpecification < Gem::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/rubygems/test_gem_stub_specification.rb#L33 assert_equal %w[ext/stub_e/extconf.rb], stub.extensions end + def test_initialize_version + stub = stub_with_version + + assert_equal 'stub_v', stub.name + assert_equal v(2), stub.version + end + + def test_initialize_with_empty_version + stub = stub_without_version + + assert_equal 'stub_v', stub.name + assert_equal v(0), stub.version + end + def test_initialize_missing_stubline stub = Gem::StubSpecification.gemspec_stub(BAR, @base_dir, @gems_dir) assert_equal "bar", stub.name @@ -164,6 +178,53 @@ class TestStubSpecification < Gem::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/rubygems/test_gem_stub_specification.rb#L178 assert stub.to_spec.instance_variable_get :@ignored end + def stub_with_version + spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' + open spec, 'w' do |io| + io.write <<-STUB +# -*- encoding: utf-8 -*- +# stub: stub_v 2 ruby lib + +Gem::Specification.new do |s| + s.name = 'stub_v' + s.version = Gem::Version.new '2' +end + STUB + + io.flush + + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + + yield stub if block_given? + + return stub + end + end + + def stub_without_version + spec = File.join @gemhome, 'specifications', 'stub-2.gemspec' + open spec, 'w' do |io| + io.write <<-STUB +# -*- encoding: utf-8 -*- +# stub: stub_v ruby lib + +Gem::Specification.new do |s| + s.name = 'stub_v' + s.version = "" +end + STUB + + io.flush + + stub = Gem::StubSpecification.gemspec_stub io.path, @gemhome, File.join(@gemhome, 'gems') + + yield stub if block_given? + + return stub + end + + end + def stub_with_extension spec = File.join @gemhome, 'specifications', 'stub_e-2.gemspec' open spec, 'w' do |io| Index: ruby_2_4/test/rubygems/test_require.rb =================================================================== --- ruby_2_4/test/rubygems/test_require.rb (revision 57951) +++ ruby_2_4/test/rubygems/test_require.rb (revision 57952) @@ -341,6 +341,31 @@ class TestGemRequire < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/rubygems/test_require.rb#L341 Kernel::RUBYGEMS_ACTIVATION_MONITOR.exit end + def test_require_when_gem_defined + default_gem_spec = new_default_spec("default", "2.0.0.0", + nil, "default/gem.rb") + install_default_specs(default_gem_spec) + c = Class.new do + def self.gem(*args) + raise "received #gem with #{args.inspect}" + end + end + assert c.send(:require, "default/gem") + assert_equal %w(default-2.0.0.0), loaded_spec_names + end + + def test_require_default_when_gem_defined + a = new_spec("a", "1", nil, "lib/a.rb") + install_specs a + c = Class.new do + def self.gem(*args) + raise "received #gem with #{args.inspect}" + end + end + assert c.send(:require, "a") + assert_equal %w(a-1), loaded_spec_names + end + def silence_warnings old_verbose, $VERBOSE = $VERBOSE, false yield Index: ruby_2_4/test/rubygems/test_gem.rb ============================================================ (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/