[前][次][番号順一覧][スレッド一覧]

ruby-changes:31635

From: drbrain <ko1@a...>
Date: Tue, 19 Nov 2013 09:34:35 +0900 (JST)
Subject: [ruby-changes:31635] drbrain:r43714 (trunk): * lib/rubygems: Update to RubyGems master 6a3d9f9. Changes include:

drbrain	2013-11-19 09:34:13 +0900 (Tue, 19 Nov 2013)

  New Revision: 43714

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43714

  Log:
    * lib/rubygems:  Update to RubyGems master 6a3d9f9.  Changes include:
    
      Compatibly renamed Gem::DependencyResolver to Gem::Resolver.
    
      Added support for git gems in gem.deps.rb and Gemfile.
    
      Fixed resolver bugs.
    
    * test/rubygems: ditto.
    
    * lib/rubygems/LICENSE.txt:  Updated to license from RubyGems trunk.
      [ruby-trunk - Bug #9086]
    
    * lib/rubygems/commands/which_command.rb:  RubyGems now indicates
      failure when any file is missing.  [ruby-trunk - Bug #9004]
    
    * lib/rubygems/ext/builder:  Extensions are now installed into the
      extension install directory and the first directory in the require
      path from the gem.  This allows backwards compatibility with msgpack
      and other gems that calculate full require paths.
      [ruby-trunk - Bug #9106]

  Added directories:
    trunk/lib/rubygems/resolver/
  Added files:
    trunk/lib/rubygems/resolver/activation_request.rb
    trunk/lib/rubygems/resolver/api_set.rb
    trunk/lib/rubygems/resolver/api_specification.rb
    trunk/lib/rubygems/resolver/best_set.rb
    trunk/lib/rubygems/resolver/composed_set.rb
    trunk/lib/rubygems/resolver/conflict.rb
    trunk/lib/rubygems/resolver/current_set.rb
    trunk/lib/rubygems/resolver/dependency_request.rb
    trunk/lib/rubygems/resolver/git_set.rb
    trunk/lib/rubygems/resolver/git_specification.rb
    trunk/lib/rubygems/resolver/index_set.rb
    trunk/lib/rubygems/resolver/index_specification.rb
    trunk/lib/rubygems/resolver/installed_specification.rb
    trunk/lib/rubygems/resolver/installer_set.rb
    trunk/lib/rubygems/resolver/lock_set.rb
    trunk/lib/rubygems/resolver/requirement_list.rb
    trunk/lib/rubygems/resolver/set.rb
    trunk/lib/rubygems/resolver/spec_specification.rb
    trunk/lib/rubygems/resolver/specification.rb
    trunk/lib/rubygems/resolver/vendor_set.rb
    trunk/lib/rubygems/resolver/vendor_specification.rb
    trunk/lib/rubygems/resolver.rb
    trunk/lib/rubygems/source/git.rb
    trunk/lib/rubygems/util/stringio.rb
    trunk/lib/rubygems/util.rb
    trunk/test/rubygems/test_gem_resolver.rb
    trunk/test/rubygems/test_gem_resolver_activation_request.rb
    trunk/test/rubygems/test_gem_resolver_api_set.rb
    trunk/test/rubygems/test_gem_resolver_api_specification.rb
    trunk/test/rubygems/test_gem_resolver_best_set.rb
    trunk/test/rubygems/test_gem_resolver_conflict.rb
    trunk/test/rubygems/test_gem_resolver_dependency_request.rb
    trunk/test/rubygems/test_gem_resolver_git_set.rb
    trunk/test/rubygems/test_gem_resolver_git_specification.rb
    trunk/test/rubygems/test_gem_resolver_index_set.rb
    trunk/test/rubygems/test_gem_resolver_index_specification.rb
    trunk/test/rubygems/test_gem_resolver_installed_specification.rb
    trunk/test/rubygems/test_gem_resolver_installer_set.rb
    trunk/test/rubygems/test_gem_resolver_lock_set.rb
    trunk/test/rubygems/test_gem_resolver_requirement_list.rb
    trunk/test/rubygems/test_gem_resolver_vendor_set.rb
    trunk/test/rubygems/test_gem_resolver_vendor_specification.rb
    trunk/test/rubygems/test_gem_source_git.rb
    trunk/test/rubygems/test_gem_util.rb
  Removed directories:
    trunk/lib/rubygems/dependency_resolver/
  Removed files:
    trunk/lib/rubygems/dependency_resolver.rb
    trunk/test/rubygems/test_gem_dependency_resolver.rb
    trunk/test/rubygems/test_gem_dependency_resolver_activation_request.rb
    trunk/test/rubygems/test_gem_dependency_resolver_api_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_api_specification.rb
    trunk/test/rubygems/test_gem_dependency_resolver_best_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb
    trunk/test/rubygems/test_gem_dependency_resolver_dependency_request.rb
    trunk/test/rubygems/test_gem_dependency_resolver_index_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_index_specification.rb
    trunk/test/rubygems/test_gem_dependency_resolver_installed_specification.rb
    trunk/test/rubygems/test_gem_dependency_resolver_installer_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_lock_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_vendor_set.rb
    trunk/test/rubygems/test_gem_dependency_resolver_vendor_specification.rb
  Modified files:
    trunk/ChangeLog
    trunk/lib/rubygems/LICENSE.txt
    trunk/lib/rubygems/available_set.rb
    trunk/lib/rubygems/basic_specification.rb
    trunk/lib/rubygems/commands/install_command.rb
    trunk/lib/rubygems/commands/which_command.rb
    trunk/lib/rubygems/dependency_installer.rb
    trunk/lib/rubygems/doctor.rb
    trunk/lib/rubygems/errors.rb
    trunk/lib/rubygems/exceptions.rb
    trunk/lib/rubygems/ext/builder.rb
    trunk/lib/rubygems/ext/cmake_builder.rb
    trunk/lib/rubygems/ext/configure_builder.rb
    trunk/lib/rubygems/ext/ext_conf_builder.rb
    trunk/lib/rubygems/ext/rake_builder.rb
    trunk/lib/rubygems/remote_fetcher.rb
    trunk/lib/rubygems/request_set/gem_dependency_api.rb
    trunk/lib/rubygems/request_set/lockfile.rb
    trunk/lib/rubygems/request_set.rb
    trunk/lib/rubygems/source/installed.rb
    trunk/lib/rubygems/source/local.rb
    trunk/lib/rubygems/source/specific_file.rb
    trunk/lib/rubygems/source/vendor.rb
    trunk/lib/rubygems/source.rb
    trunk/lib/rubygems/source_list.rb
    trunk/lib/rubygems/spec_fetcher.rb
    trunk/lib/rubygems/specification.rb
    trunk/lib/rubygems/test_case.rb
    trunk/lib/rubygems.rb
    trunk/test/rubygems/test_gem.rb
    trunk/test/rubygems/test_gem_commands_which_command.rb
    trunk/test/rubygems/test_gem_dependency_resolution_error.rb
    trunk/test/rubygems/test_gem_ext_builder.rb
    trunk/test/rubygems/test_gem_impossible_dependencies_error.rb
    trunk/test/rubygems/test_gem_installer.rb
    trunk/test/rubygems/test_gem_remote_fetcher.rb
    trunk/test/rubygems/test_gem_request_set.rb
    trunk/test/rubygems/test_gem_request_set_gem_dependency_api.rb
    trunk/test/rubygems/test_gem_request_set_lockfile.rb
    trunk/test/rubygems/test_gem_source.rb
    trunk/test/rubygems/test_gem_source_vendor.rb
    trunk/test/rubygems/test_gem_specification.rb
    trunk/test/rubygems/test_gem_stub_specification.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43713)
+++ ChangeLog	(revision 43714)
@@ -1,3 +1,28 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Nov 19 09:33:52 2013  Eric Hodel  <drbrain@s...>
+
+	* lib/rubygems:  Update to RubyGems master 6a3d9f9.  Changes include:
+
+	  Compatibly renamed Gem::DependencyResolver to Gem::Resolver.
+
+	  Added support for git gems in gem.deps.rb and Gemfile.
+
+	  Fixed resolver bugs.
+
+	* test/rubygems: ditto.
+
+	* lib/rubygems/LICENSE.txt:  Updated to license from RubyGems trunk.
+	  [ruby-trunk - Bug #9086]
+
+	* lib/rubygems/commands/which_command.rb:  RubyGems now indicates
+	  failure when any file is missing.  [ruby-trunk - Bug #9004]
+
+	* lib/rubygems/ext/builder:  Extensions are now installed into the
+	  extension install directory and the first directory in the require
+	  path from the gem.  This allows backwards compatibility with msgpack
+	  and other gems that calculate full require paths.
+	  [ruby-trunk - Bug #9106]
+
+
 Tue Nov 19 07:21:56 2013  Tanaka Akira  <akr@f...>
 
 	* configure.in (LOCALTIME_OVERFLOW_PROBLEM): Define it for cross
Index: lib/rubygems/dependency_resolver.rb
===================================================================
--- lib/rubygems/dependency_resolver.rb	(revision 43713)
+++ lib/rubygems/dependency_resolver.rb	(revision 43714)
@@ -1,364 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_resolver.rb#L0
-require 'rubygems'
-require 'rubygems/dependency'
-require 'rubygems/exceptions'
-require 'rubygems/util/list'
-
-require 'uri'
-require 'net/http'
-
-##
-# Given a set of Gem::Dependency objects as +needed+ and a way to query the
-# set of available specs via +set+, calculates a set of ActivationRequest
-# objects which indicate all the specs that should be activated to meet the
-# all the requirements.
-
-class Gem::DependencyResolver
-
-  ##
-  # Contains all the conflicts encountered while doing resolution
-
-  attr_reader :conflicts
-
-  attr_accessor :development
-
-  attr_reader :missing
-
-  ##
-  # When a missing dependency, don't stop. Just go on and record what was
-  # missing.
-
-  attr_accessor :soft_missing
-
-  def self.compose_sets *sets
-    sets.compact!
-
-    case sets.length
-    when 0 then
-      raise ArgumentError, 'one set in the composition must be non-nil'
-    when 1 then
-      sets.first
-    else
-      Gem::DependencyResolver::ComposedSet.new(*sets)
-    end
-  end
-
-  ##
-  # Provide a DependencyResolver that queries only against the already
-  # installed gems.
-
-  def self.for_current_gems needed
-    new needed, Gem::DependencyResolver::CurrentSet.new
-  end
-
-  ##
-  # Create DependencyResolver object which will resolve the tree starting
-  # with +needed+ Dependency objects.
-  #
-  # +set+ is an object that provides where to look for specifications to
-  # satisfy the Dependencies. This defaults to IndexSet, which will query
-  # rubygems.org.
-
-  def initialize needed, set = nil
-    @set = set || Gem::DependencyResolver::IndexSet.new
-    @needed = needed
-
-    @conflicts    = []
-    @development  = false
-    @missing      = []
-    @soft_missing = false
-  end
-
-  ##
-  # Creates an ActivationRequest for the given +dep+ and the last +possible+
-  # specification.
-  #
-  # Returns the Specification and the ActivationRequest
-
-  def activation_request dep, possible # :nodoc:
-    spec = possible.pop
-
-    activation_request =
-      Gem::DependencyResolver::ActivationRequest.new spec, dep, possible
-
-    return spec, activation_request
-  end
-
-  def requests s, act, reqs=nil
-    s.dependencies.reverse_each do |d|
-      next if d.type == :development and not @development
-      reqs = Gem::List.new Gem::DependencyResolver::DependencyRequest.new(d, act), reqs
-    end
-
-    @set.prefetch reqs
-
-    reqs
-  end
-
-  ##
-  # Proceed with resolution! Returns an array of ActivationRequest objects.
-
-  def resolve
-    @conflicts = []
-
-    needed = nil
-
-    @needed.reverse_each do |n|
-      request = Gem::DependencyResolver::DependencyRequest.new n, nil
-
-      needed = Gem::List.new request, needed
-    end
-
-    res = resolve_for needed, nil
-
-    raise Gem::DependencyResolutionError, res if
-      res.kind_of? Gem::DependencyResolver::DependencyConflict
-
-    res.to_a
-  end
-
-  ##
-  # Finds the State in +states+ that matches the +conflict+ so that we can try
-  # other possible sets.
-  #
-  # If no good candidate is found, the first state is tried.
-
-  def find_conflict_state conflict, states # :nodoc:
-    rejected = []
-
-    until states.empty? do
-      state = states.pop
-
-      if conflict.for_spec? state.spec
-        state.conflicts << [state.spec, conflict]
-        return state
-      end
-
-      rejected << state
-    end
-
-    return rejected.shift
-  ensure
-    rejected = rejected.concat states
-    states.replace rejected
-  end
-
-  ##
-  # Extracts the specifications that may be able to fulfill +dependency+ and
-  # returns those that match the local platform and all those that match.
-
-  def find_possible dependency # :nodoc:
-    all = @set.find_all dependency
-    matching_platform = select_local_platforms all
-
-    return matching_platform, all
-  end
-
-  def handle_conflict(dep, existing)
-    # There is a conflict! We return the conflict object which will be seen by
-    # the caller and be handled at the right level.
-
-    # If the existing activation indicates that there are other possibles for
-    # it, then issue the conflict on the dependency for the activation itself.
-    # Otherwise, issue it on the requester's request itself.
-    if existing.others_possible? or existing.request.requester.nil? then
-      conflict =
-        Gem::DependencyResolver::DependencyConflict.new dep, existing
-    else
-      depreq = existing.request.requester.request
-      conflict =
-        Gem::DependencyResolver::DependencyConflict.new depreq, existing, dep
-    end
-
-    @conflicts << conflict unless @conflicts.include? conflict
-
-    return conflict
-  end
-
-  # Contains the state for attempting activation of a set of possible specs.
-  # +needed+ is a Gem::List of DependencyRequest objects that, well, need
-  # to be satisfied.
-  # +specs+ is the List of ActivationRequest that are being tested.
-  # +dep+ is the DependencyRequest that was used to generate this state.
-  # +spec+ is the Specification for this state.
-  # +possible+ is List of DependencyRequest objects that can be tried to
-  # find a  complete set.
-  # +conflicts+ is a [DependencyRequest, DependencyConflict] hit tried to
-  # activate the state.
-  #
-  State = Struct.new(:needed, :specs, :dep, :spec, :possibles, :conflicts) do
-    def summary # :nodoc:
-      nd = needed.map { |s| s.to_s }.sort if nd
-
-      if specs then
-        ss = specs.map { |s| s.full_name }.sort
-        ss.unshift ss.length
-      end
-
-      d = dep.to_s
-      d << " from #{dep.requester.full_name}" if dep.requester
-
-      ps = possibles.map { |p| p.full_name }.sort
-      ps.unshift ps.length
-
-      cs = conflicts.map do |(s, c)|
-        [s.full_name, c.conflicting_dependencies.map { |cd| cd.to_s }]
-      end
-
-      { :needed => nd, :specs => ss, :dep => d, :spec => spec.full_name,
-        :possibles => ps, :conflicts => cs }
-    end
-  end
-
-  ##
-  # The meat of the algorithm. Given +needed+ DependencyRequest objects and
-  # +specs+ being a list to ActivationRequest, calculate a new list of
-  # ActivationRequest objects.
-
-  def resolve_for needed, specs
-    # The State objects that are used to attempt the activation tree.
-    states = []
-
-    while needed
-      dep = needed.value
-      needed = needed.tail
-
-      # If there is already a spec activated for the requested name...
-      if specs && existing = specs.find { |s| dep.name == s.name }
-        # then we're done since this new dep matches the existing spec.
-        next if dep.matches_spec? existing
-
-        conflict = handle_conflict dep, existing
-
-        state = find_conflict_state conflict, states
-
-        return conflict unless state
-
-        needed, specs = resolve_for_conflict needed, specs, state
-
-        states << state unless state.possibles.empty?
-
-        next
-      end
-
-      matching, all = find_possible dep
-
-      case matching.size
-      when 0
-        resolve_for_zero dep, all
-      when 1
-        needed, specs =
-          resolve_for_single needed, specs, dep, matching
-      else
-        needed, specs =
-          resolve_for_multiple needed, specs, states, dep, matching
-      end
-    end
-
-    specs
-  end
-
-  ##
-  # Rewinds +needed+ and +specs+ to a previous state in +state+ for a conflict
-  # between +dep+ and +existing+.
-
-  def resolve_for_conflict needed, specs, state # :nodoc:
-    # We exhausted the possibles so it's definitely not going to work out,
-    # bail out.
-    raise Gem::ImpossibleDependenciesError.new state.dep, state.conflicts if
-      state.possibles.empty?
-
-    # Retry resolution with this spec and add it's dependencies
-    spec, act = activation_request state.dep, state.possibles
-
-    needed = requests spec, act, state.needed
-    specs = Gem::List.prepend state.specs, act
-
-    return needed, specs
-  end
-
-  ##
-  # There are multiple +possible+ specifications for this +dep+.  Updates
-  # +needed+, +specs+ and +states+ for further resolution of the +possible+
-  # choices.
-
-  def resolve_for_multiple needed, specs, states, dep, possible # :nodoc:
-    # Sort them so that we try the highest versions first.
-    possible = possible.sort_by do |s|
-      [s.source, s.version, s.platform == Gem::Platform::RUBY ? -1 : 1]
-    end
-
-    spec, act = activation_request dep, possible
-
-    # We may need to try all of +possible+, so we setup state to unwind back
-    # to current +needed+ and +specs+ so we can try another. This is code is
-    # what makes conflict resolution possible.
-    states << State.new(needed, specs, dep, spec, possible, [])
-
-    needed = requests spec, act, needed
-    specs = Gem::List.prepend specs, act
-
-    return needed, specs
-  end
-
-  ##
-  # Add the spec from the +possible+ list to +specs+ and process the spec's
-  # dependencies by adding them to +needed+.
-
-  def resolve_for_single needed, specs, dep, possible # :nodoc:
-    spec, act = activation_request dep, possible
-
-    specs = Gem::List.prepend specs, act
-
-    # Put the deps for at the beginning of needed
-    # rather than the end to match the depth first
-    # searching done by the multiple case code below.
-    #
-    # This keeps the error messages consistent.
-    needed = requests spec, act, needed
-
-    return needed, specs
-  end
-
-  ##
-  # When there are no possible specifications for +dep+ our work is done.
-
-  def resolve_for_zero dep, platform_mismatch # :nodoc:
-    @missing << dep
-
-    unless @soft_missing
-      raise Gem::UnsatisfiableDependencyError.new(dep, platform_mismatch)
-    end
-  end
-
-  ##
-  # Returns the gems in +specs+ that match the local platform.
-
-  def select_local_platforms specs # :nodoc:
-    specs.select do |spec|
-      Gem::Platform.installable? spec
-    end
-  end
-
-end
-
-require 'rubygems/dependency_resolver/activation_request'
-require 'rubygems/dependency_resolver/dependency_conflict'
-require 'rubygems/dependency_resolver/dependency_request'
-
-require 'rubygems/dependency_resolver/set'
-require 'rubygems/dependency_resolver/api_set'
-require 'rubygems/dependency_resolver/composed_set'
-require 'rubygems/dependency_resolver/best_set'
-require 'rubygems/dependency_resolver/current_set'
-require 'rubygems/dependency_resolver/index_set'
-require 'rubygems/dependency_resolver/installer_set'
-require 'rubygems/dependency_resolver/lock_set'
-require 'rubygems/dependency_resolver/vendor_set'
-
-require 'rubygems/dependency_resolver/specification'
-require 'rubygems/dependency_resolver/spec_specification'
-require 'rubygems/dependency_resolver/api_specification'
-require 'rubygems/dependency_resolver/index_specification'
-require 'rubygems/dependency_resolver/installed_specification'
-require 'rubygems/dependency_resolver/vendor_specification'
-
Index: lib/rubygems/basic_specification.rb
===================================================================
--- lib/rubygems/basic_specification.rb	(revision 43713)
+++ lib/rubygems/basic_specification.rb	(revision 43714)
@@ -107,7 +107,7 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L107
       File.join full_gem_path, path
     end
 
-    full_paths << extension_install_dir unless @extensions.empty?
+    full_paths.unshift extension_install_dir unless @extensions.empty?
 
     full_paths
   end
@@ -155,6 +155,10 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L155
     raise NotImplementedError
   end
 
+  def raw_require_paths # :nodoc:
+    @require_paths
+  end
+
   ##
   # Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
   # activated.
@@ -179,7 +183,7 @@ class Gem::BasicSpecification https://github.com/ruby/ruby/blob/trunk/lib/rubygems/basic_specification.rb#L183
       File.join '..', '..', 'extensions', Gem::Platform.local.to_s,
                 Gem.extension_api_version, full_name
 
-    @require_paths + [relative_extension_install_dir]
+    [relative_extension_install_dir].concat @require_paths
   end
 
   ##
Index: lib/rubygems/spec_fetcher.rb
===================================================================
--- lib/rubygems/spec_fetcher.rb	(revision 43713)
+++ lib/rubygems/spec_fetcher.rb	(revision 43714)
@@ -34,6 +34,10 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L34
 
   @fetcher = nil
 
+  ##
+  # Default fetcher instance.  Use this instead of ::new to reduce object
+  # allocation.
+
   def self.fetcher
     @fetcher ||= new
   end
@@ -43,8 +47,8 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L47
   end
 
   ##
-  # Creates a new SpecFetcher.  Ordinarily you want to use
-  # Gem::SpecFetcher::fetcher which uses the Gem.sources.
+  # Creates a new SpecFetcher.  Ordinarily you want to use the default fetcher
+  # from Gem::SpecFetcher::fetcher which uses the Gem.sources.
   #
   # If you need to retrieve specifications from a different +source+, you can
   # send it as an argument.
@@ -84,7 +88,11 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L88
     rejected_specs = {}
 
     if dependency.prerelease?
-      type = :complete
+      if dependency.specific?
+        type = :complete
+      else
+        type = :abs_latest
+      end
     elsif dependency.latest_version?
       type = :latest
     else
@@ -224,6 +232,12 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L232
                     tuples_for(source, :released)
 
                   names.sort
+                when :abs_latest
+                  names =
+                    tuples_for(source, :prerelease, true) +
+                    tuples_for(source, :latest)
+
+                  names.sort
                 when :prerelease
                   tuples_for(source, :prerelease)
                 else
@@ -239,7 +253,11 @@ class Gem::SpecFetcher https://github.com/ruby/ruby/blob/trunk/lib/rubygems/spec_fetcher.rb#L253
     [list, errors]
   end
 
-  def tuples_for(source, type, gracefully_ignore=false)
+  ##
+  # Retrieves NameTuples from +source+ of the given +type+ (:prerelease,
+  # etc.).  If +gracefully_ignore+ is true, errors are ignored.
+
+  def tuples_for(source, type, gracefully_ignore=false) # :nodoc:
     cache = @caches[type]
 
     tuples =
Index: lib/rubygems/available_set.rb
===================================================================
--- lib/rubygems/available_set.rb	(revision 43713)
+++ lib/rubygems/available_set.rb	(revision 43714)
@@ -116,7 +116,7 @@ class Gem::AvailableSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/available_set.rb#L116
 
   ##
   #
-  # Used by the DependencyResolver, the protocol to use a AvailableSet as a
+  # Used by the Resolver, the protocol to use a AvailableSet as a
   # search Set.
 
   def find_all(req)
@@ -127,7 +127,7 @@ class Gem::AvailableSet https://github.com/ruby/ruby/blob/trunk/lib/rubygems/available_set.rb#L127
     end
 
     match.map do |t|
-      Gem::DependencyResolver::InstalledSpecification.new(self, t.spec, t.source)
+      Gem::Resolver::InstalledSpecification.new(self, t.spec, t.source)
     end
   end
 
Index: lib/rubygems/dependency_installer.rb
===================================================================
--- lib/rubygems/dependency_installer.rb	(revision 43713)
+++ lib/rubygems/dependency_installer.rb	(revision 43714)
@@ -1,6 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L1
 require 'rubygems'
 require 'rubygems/dependency_list'
-require 'rubygems/dependency_resolver'
 require 'rubygems/package'
 require 'rubygems/installer'
 require 'rubygems/spec_fetcher'
@@ -196,7 +195,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L195
   # sources.  Gems are sorted with newer gems preferred over older gems, and
   # local gems preferred over remote gems.
 
-  def find_gems_with_sources dep # :nodoc:
+  def find_gems_with_sources dep, best_only=false # :nodoc:
     set = Gem::AvailableSet.new
 
     if consider_local?
@@ -211,7 +210,26 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L210
 
     if consider_remote?
       begin
-        found, errors = Gem::SpecFetcher.fetcher.spec_for_dependency dep
+        # TODO this is pulled from #spec_for_dependency to allow
+        # us to filter tuples before fetching specs.
+        #
+        tuples, errors = Gem::SpecFetcher.fetcher.search_for_dependency dep
+
+        if best_only && !tuples.empty?
+          tuples.sort! { |a,b| b[0].version <=> a[0].version }
+          tuples = [tuples.first]
+        end
+
+        specs = []
+        tuples.each do |tup, source|
+          begin
+            spec = source.fetch_spec(tup)
+          rescue Gem::RemoteFetcher::FetchError => e
+            errors << Gem::SourceFetchProblem.new(source, e)
+          else
+            specs << [spec, source]
+          end
+        end
 
         if @errors
           @errors += errors
@@ -219,7 +237,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L237
           @errors = errors
         end
 
-        set << found
+        set << specs
 
       rescue Gem::RemoteFetcher::FetchError => e
         # FIX if there is a problem talking to the network, we either need to always tell
@@ -271,7 +289,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L289
       dep = Gem::Dependency.new gem_name, version
       dep.prerelease = true if prerelease
 
-      set = find_gems_with_sources(dep)
+      set = find_gems_with_sources(dep, true)
       set.match_platform!
     end
 
@@ -402,7 +420,7 @@ class Gem::DependencyInstaller https://github.com/ruby/ruby/blob/trunk/lib/rubygems/dependency_installer.rb#L420
     request_set = as.to_request_set install_development_deps
     request_set.soft_missing = @force
 
-    installer_set = Gem::DependencyResolver::InstallerSet.new @domain
+    installer_set = Gem::Resolver::InstallerSet.new @domain
     installer_set.always_install.concat request_set.always_install
     installer_set.ignore_installed = @only_install_dir
 
@@ -411,7 +429,7 @@ class Gem::DependencyInstaller https://github.com (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]