diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-21 23:27:30 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-21 23:27:30 +0000 |
commit | 5307d803f5cce7b14a6afd1d51f6d53ec85ca87d (patch) | |
tree | aac2997a9ff000fbf2f1f9f27077bb7b2403f2c9 /lib/rubygems/resolver.rb | |
parent | b1529a30e08040b717adef8ac1fa8be1c060e7e1 (diff) | |
download | ruby-5307d803f5cce7b14a6afd1d51f6d53ec85ca87d.tar.gz |
* lib/rubygems: Update to RubyGems master 50a8210. Important changes
in this commit:
RubyGems now automatically checks for gem.deps.rb or Gemfile when
running ruby executables. This behavior is similar to `bundle exec
rake`. This change may be reverted before Ruby 2.1.0 if too many bugs
are found.
* test/rubygems: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/resolver.rb')
-rw-r--r-- | lib/rubygems/resolver.rb | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/lib/rubygems/resolver.rb b/lib/rubygems/resolver.rb index 2669cc4f24..828c61de01 100644 --- a/lib/rubygems/resolver.rb +++ b/lib/rubygems/resolver.rb @@ -29,9 +29,23 @@ class Gem::Resolver attr_accessor :soft_missing + ## + # Combines +sets+ into a ComposedSet that allows specification lookup in a + # uniform manner. If one of the +sets+ is itself a ComposedSet its sets are + # flattened into the result ComposedSet. + def self.compose_sets *sets sets.compact! + sets = sets.map do |set| + case set + when Gem::Resolver::ComposedSet then + set.sets + else + set + end + end.flatten + case sets.length when 0 then raise ArgumentError, 'one set in the composition must be non-nil' @@ -77,6 +91,15 @@ class Gem::Resolver end end + def explain_list(stage, data) + if DEBUG_RESOLVER + STDOUT.printf "%20s (%d entries)\n", stage.to_s.upcase, data.size + data.each do |d| + STDOUT.printf "%20s %s\n", "", d + end + end + end + ## # Creates an ActivationRequest for the given +dep+ and the last +possible+ # specification. @@ -134,8 +157,6 @@ class Gem::Resolver # 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 @@ -145,14 +166,9 @@ class Gem::Resolver state.conflicts << [state.spec, conflict] return state end - - rejected << state end - return rejected.shift - ensure - rejected = rejected.concat states - states.replace rejected + nil end ## @@ -172,14 +188,23 @@ class Gem::Resolver # 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 + # Otherwise, if there was a requester, issue it on the requester's + # request itself. + # Finally, if the existing request has no requester (toplevel) unwind to + # it anyway. + + if existing.others_possible? conflict = Gem::Resolver::Conflict.new dep, existing - else + elsif dep.requester depreq = dep.requester.request conflict = Gem::Resolver::Conflict.new depreq, existing, dep + elsif existing.request.requester.nil? + conflict = + Gem::Resolver::Conflict.new dep, existing + else + raise Gem::DependencyError, "Unable to figure out how to unwind conflict" end @conflicts << conflict unless @conflicts.include? conflict @@ -234,6 +259,8 @@ class Gem::Resolver while !needed.empty? dep = needed.remove explain :try, [dep, dep.requester ? dep.requester.request : :toplevel] + explain_list :next5, needed.next5 + explain_list :specs, Array(specs).map { |x| x.full_name }.sort # If there is already a spec activated for the requested name... if specs && existing = specs.find { |s| dep.name == s.name } @@ -284,7 +311,7 @@ class Gem::Resolver # Retry resolution with this spec and add it's dependencies spec, act = activation_request state.dep, state.possibles - needed = requests spec, act, state.needed + needed = requests spec, act, state.needed.dup specs = Gem::List.prepend state.specs, act return needed, specs |