method
fixup_swapped_children
v2_6_3 -
Show latest stable
- Class:
Gem::Resolver::Molinillo::Resolver::Resolution
fixup_swapped_children(vertex)private
Ensures there are no orphaned successors to the given {vertex}. @param [DependencyGraph::Vertex] vertex the vertex to fix up. @return [void]
# File lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb, line 359
def fixup_swapped_children(vertex) # rubocop:disable Metrics/CyclomaticComplexity
payload = vertex.payload
deps = dependencies_for(payload).group_by(&method(:name_for))
vertex.outgoing_edges.each do |outgoing_edge|
requirement = outgoing_edge.requirement
parent_index = @parents_of[requirement].last
succ = outgoing_edge.destination
matching_deps = Array(deps[succ.name])
dep_matched = matching_deps.include?(requirement)
# only push the current index when it was originally required by the
# same named spec
if parent_index && states[parent_index].name == name
@parents_of[requirement].push(states.size - 1)
end
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| @parents_of.delete(r) }
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 !dep_matched
debug(depth) { "Removing orphaned dependency #{requirement} after swapping #{name}" }
# also reset if we're removing the edge, but only if its parent has
# already been fixed up
@parents_of[requirement].push(states.size - 1) if @parents_of[requirement].empty?
activated.delete_edge(outgoing_edge)
requirements.delete(requirement)
end
end
end Related methods
- Instance methods
- resolve
- Class methods
- new
- Private methods
-
activate_spec -
attempt_to_activate -
attempt_to_activate_existing_spec -
attempt_to_activate_new_spec -
attempt_to_swap_possibility -
create_conflict -
debug -
end_resolution -
find_state_for -
fixup_swapped_children -
handle_missing_or_push_dependency_state -
indicate_progress -
initial_state -
locked_requirement_named -
new_spec_satisfied? -
parent_of -
possibility -
process_topmost_state -
push_state_for_requirements -
require_nested_dependencies_for -
requirement_for_existing_name -
requirement_tree_for -
requirement_trees -
start_resolution -
state -
state_any? -
state_index_for_unwind -
unwind_for_conflict