From 5a90f9e8f84533e7859232895fc4bbe6b31cc771 Mon Sep 17 00:00:00 2001 From: hsbt Date: Fri, 4 Mar 2016 00:29:40 +0000 Subject: * 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/resolver/installer_set.rb | 12 +++-- .../molinillo/lib/molinillo/dependency_graph.rb | 4 ++ .../molinillo/lib/molinillo/gem_metadata.rb | 2 +- .../resolver/molinillo/lib/molinillo/modules/ui.rb | 3 +- .../resolver/molinillo/lib/molinillo/resolution.rb | 51 ++++++++++++++++------ 5 files changed, 52 insertions(+), 20 deletions(-) (limited to 'lib/rubygems/resolver') diff --git a/lib/rubygems/resolver/installer_set.rb b/lib/rubygems/resolver/installer_set.rb index 1ed02e6f9f..07fffeb150 100644 --- a/lib/rubygems/resolver/installer_set.rb +++ b/lib/rubygems/resolver/installer_set.rb @@ -138,10 +138,14 @@ class Gem::Resolver::InstallerSet < Gem::Resolver::Set 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 diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb index deb4659448..42563664d6 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb @@ -127,6 +127,10 @@ module Gem::Resolver::Molinillo 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 diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb index 79cae2c697..1b66500f0f 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Gem::Resolver::Molinillo # The version of Gem::Resolver::Molinillo. - VERSION = '0.4.1'.freeze + VERSION = '0.4.3'.freeze end diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb index 348ace286a..540b5b809c 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb @@ -58,7 +58,8 @@ module Gem::Resolver::Molinillo # # @return [Boolean] def debug? - @debug_mode ||= ENV['MOLINILLO_DEBUG'] + return @debug_mode if defined?(@debug_mode) + @debug_mode = ENV['MOLINILLO_DEBUG'] end end end diff --git a/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb b/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb index 0f822f0b82..2fc18843fe 100644 --- a/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb +++ b/lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb @@ -342,26 +342,37 @@ module Gem::Resolver::Molinillo # @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 vertex to fix up. + # @return [void] + def fixup_swapped_children(vertex) + payload = vertex.payload + dep_names = dependencies_for(payload).map(&method(:name_for)) + vertex.successors.each do |succ| + if !dep_names.include?(succ.name) && !succ.root? && succ.predecessors.to_a == [vertex] + debug(depth) { "Removing orphaned spec #{succ.name} after swapping #{name}" } + activated.detach_vertex_named(succ.name) + requirements.delete_if { |r| name_for(r) == succ.name } + end + end end # Attempts to activate the current {#possibility} (given that it hasn't # already been activated) # @return [void] def attempt_to_activate_new_spec - satisfied = begin - locked_requirement = locked_requirement_named(name) - requested_spec_satisfied = requirement_satisfied_by?(requirement, activated, possibility) - locked_spec_satisfied = !locked_requirement || - requirement_satisfied_by?(locked_requirement, activated, possibility) - debug(depth) { 'Unsatisfied by requested spec' } unless requested_spec_satisfied - debug(depth) { 'Unsatisfied by locked spec' } unless locked_spec_satisfied - requested_spec_satisfied && locked_spec_satisfied - end - if satisfied + if new_spec_satisfied? activate_spec else create_conflict @@ -369,6 +380,18 @@ module Gem::Resolver::Molinillo end end + # @return [Boolean] whether the current spec is satisfied as a new + # possibility. + def new_spec_satisfied? + locked_requirement = locked_requirement_named(name) + requested_spec_satisfied = requirement_satisfied_by?(requirement, activated, possibility) + locked_spec_satisfied = !locked_requirement || + requirement_satisfied_by?(locked_requirement, activated, possibility) + debug(depth) { 'Unsatisfied by requested spec' } unless requested_spec_satisfied + debug(depth) { 'Unsatisfied by locked spec' } unless locked_spec_satisfied + requested_spec_satisfied && locked_spec_satisfied + end + # @param [String] requirement_name the spec name to search for # @return [Object] the locked spec named `requirement_name`, if one # is found on {#base} @@ -394,7 +417,7 @@ module Gem::Resolver::Molinillo # @return [void] def require_nested_dependencies_for(activated_spec) nested_dependencies = dependencies_for(activated_spec) - debug(depth) { "Requiring nested dependencies (#{nested_dependencies.map(&:to_s).join(', ')})" } + debug(depth) { "Requiring nested dependencies (#{nested_dependencies.join(', ')})" } nested_dependencies.each { |d| activated.add_child_vertex(name_for(d), nil, [name_for(activated_spec)], d) } push_state_for_requirements(requirements + nested_dependencies, nested_dependencies.size > 0) -- cgit v1.2.3