class Bundler::Definition

def converge_specs(specs)

def converge_specs(specs)
  converged = []
  deps = []
  specs.each do |s|
    name = s.name
    dep = @dependencies.find {|d| s.satisfies?(d) }
    lockfile_source = s.source
    if dep
      gemfile_source = dep.source || default_source
      deps << dep if !dep.source || lockfile_source.include?(dep.source)
      @gems_to_unlock << name if lockfile_source.include?(dep.source) && lockfile_source != gemfile_source
      # Replace the locked dependency's source with the equivalent source from the Gemfile
      s.source = gemfile_source
    else
      # Replace the locked dependency's source with the default source, if the locked source is no longer in the Gemfile
      s.source = default_source unless sources.get(lockfile_source)
    end
    next if @sources_to_unlock.include?(s.source.name)
    # Path sources have special logic
    if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
      new_specs = begin
        s.source.specs
      rescue PathError
        # if we won't need the source (according to the lockfile),
        # don't error if the path source isn't available
        next if specs.
                for(requested_dependencies, false).
                none? {|locked_spec| locked_spec.source == s.source }
        raise
      end
      new_spec = new_specs[s].first
      if new_spec
        s.dependencies.replace(new_spec.dependencies)
      else
        # If the spec is no longer in the path source, unlock it. This
        # commonly happens if the version changed in the gemspec
        @gems_to_unlock << name
      end
    end
    if dep.nil? && requested_dependencies.find {|d| name == d.name }
      @gems_to_unlock << s.name
    else
      converged << s
    end
  end
  filter_specs(converged, deps)
end