class Bundler::Molinillo::Resolver::Resolution

def unwind_options_for_requirements(binding_requirements)

Returns:
  • (Array) - array of UnwindDetails that have a chance

Parameters:
  • binding_requirements (Array) -- array of requirements that combine to create a conflict
    def unwind_options_for_requirements(binding_requirements)
      unwind_details = []
      trees = []
      binding_requirements.reverse_each do |r|
        partial_tree = [r]
        trees << partial_tree
        unwind_details << UnwindDetails.new(-1, nil, partial_tree, binding_requirements, trees, [])
        # If this requirement has alternative possibilities, check if any would
        # satisfy the other requirements that created this conflict
        requirement_state = find_state_for(r)
        if conflict_fixing_possibilities?(requirement_state, binding_requirements)
          unwind_details << UnwindDetails.new(
            states.index(requirement_state),
            r,
            partial_tree,
            binding_requirements,
            trees,
            []
          )
        end
        # Next, look at the parent of this requirement, and check if the requirement
        # could have been avoided if an alternative PossibilitySet had been chosen
        parent_r = parent_of(r)
        next if parent_r.nil?
        partial_tree.unshift(parent_r)
        requirement_state = find_state_for(parent_r)
        if requirement_state.possibilities.any? { |set| !set.dependencies.include?(r) }
          unwind_details << UnwindDetails.new(
            states.index(requirement_state),
            parent_r,
            partial_tree,
            binding_requirements,
            trees,
            []
          )
        end
        # Finally, look at the grandparent and up of this requirement, looking
        # for any possibilities that wouldn't create their parent requirement
        grandparent_r = parent_of(parent_r)
        until grandparent_r.nil?
          partial_tree.unshift(grandparent_r)
          requirement_state = find_state_for(grandparent_r)
          if requirement_state.possibilities.any? { |set| !set.dependencies.include?(parent_r) }
            unwind_details << UnwindDetails.new(
              states.index(requirement_state),
              grandparent_r,
              partial_tree,
              binding_requirements,
              trees,
              []
            )
          end
          parent_r = grandparent_r
          grandparent_r = parent_of(parent_r)
        end
      end
      unwind_details
    end