summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2012-03-02 15:17:52 -0800
committerYehuda Katz <wycats@gmail.com>2012-03-02 15:22:08 -0800
commitff7b89d7ad84e6a2450ee2b444aecf0a42534887 (patch)
tree2dbc09e71e19584a965b53c69d1d6e8f7760943e
parent859d3ad92e7ae4aa517ea0f7f4d09e7f4b9cab86 (diff)
downloadbundler-ff7b89d7ad84e6a2450ee2b444aecf0a42534887.tar.gz
Cherry pick perf fix from master
-rw-r--r--lib/bundler/definition.rb34
-rw-r--r--lib/bundler/source.rb7
2 files changed, 35 insertions, 6 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 4e0d7c1672..d86792106c 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -68,8 +68,8 @@ module Bundler
eager_unlock = expand_dependencies(@unlock[:gems])
@unlock[:gems] = @locked_specs.for(eager_unlock).map { |s| s.name }
- converge_sources
- converge_dependencies
+ @source_changes = converge_sources
+ @dependency_changes = converge_dependencies
fixup_dependency_types!
end
@@ -154,7 +154,7 @@ module Bundler
def resolve
@resolve ||= begin
- if Bundler.settings[:frozen]
+ if Bundler.settings[:frozen] || (!@source_changes && !@dependency_changes)
@locked_specs
else
last_resolve = converge_locked_specs
@@ -340,20 +340,42 @@ module Bundler
end
def converge_sources
+ changes = false
+
+ # Get the Rubygems source from the Gemfile.lock
locked_gem = @locked_sources.find { |s| Source::Rubygems === s }
+
+ # Get the Rubygems source from the Gemfile
actual_gem = @sources.find { |s| Source::Rubygems === s }
+ # If there is a Rubygems source in both
if locked_gem && actual_gem
- locked_gem.merge_remotes actual_gem
+ # Merge the remotes from the Gemfile into the Gemfile.lock
+ changes = changes | locked_gem.replace_remotes(actual_gem)
end
+ # Replace the sources from the Gemfile with the sources from the Gemfile.lock,
+ # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
+ # source in the Gemfile.lock, use the one from the Gemfile.
@sources.map! do |source|
@locked_sources.find { |s| s == source } || source
end
+ changes = changes | !(@sources & @locked_sources).empty?
+
@sources.each do |source|
- source.unlock! if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name)
+ # If the source is unlockable and the current command allows an unlock of
+ # the source (for example, you are doing a `bundle update <foo>` of a git-pinned
+ # gem), unlock it. For git sources, this means to unlock the revision, which
+ # will cause the `ref` used to be the most recent for the branch (or master) if
+ # an explicit `ref` is not used.
+ if source.respond_to?(:unlock!) && @unlock[:sources].include?(source.name)
+ source.unlock!
+ changes = true
+ end
end
+
+ changes
end
def converge_dependencies
@@ -362,6 +384,8 @@ module Bundler
dep.source = @sources.find { |s| dep.source == s }
end
end
+
+ (@dependencies & @locked_deps).empty?
end
# Remove elements from the locked specs that are expired. This will most
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 126e7fc4b7..58044089f6 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -127,11 +127,16 @@ module Bundler
@remotes << normalize_uri(source)
end
- def merge_remotes(source)
+ def replace_remotes(source)
+ diffs = source.remotes & @remotes
+ return false if diffs.empty?
+
@remotes = []
source.remotes.each do |r|
add_remote r.to_s
end
+
+ true
end
private