summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-02-08 14:19:16 -0600
committerSamuel Giddins <segiddins@segiddins.me>2017-02-08 14:19:16 -0600
commit65e165fb2c6c82c304628da075321362d5f9d3ee (patch)
treef067b84ff1fb5773fb3669a5d779ed7b18beb1f1 /lib
parentcad91be3c8f4ab5a71eee284c051cb2e7c2cb3a2 (diff)
downloadbundler-65e165fb2c6c82c304628da075321362d5f9d3ee.tar.gz
Update vendored Molinillo to 0.5.6seg-molinillo-0.5.6
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb13
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb11
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb2
-rw-r--r--lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb19
5 files changed, 37 insertions, 10 deletions
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
index dc090097ca..e147ded7b8 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb
@@ -98,18 +98,27 @@ module Bundler::Molinillo
"#{self.class}:#{vertices.values.inspect}"
end
+ # @param [Hash] options options for dot output.
# @return [String] Returns a dot format representation of the graph
- def to_dot
+ def to_dot(options = {})
+ edge_label = options.delete(:edge_label)
+ raise ArgumentError, "Unknown options: #{options.keys}" unless options.empty?
+
dot_vertices = []
dot_edges = []
vertices.each do |n, v|
dot_vertices << " #{n} [label=\"{#{n}|#{v.payload}}\"]"
v.outgoing_edges.each do |e|
- dot_edges << " #{e.origin.name} -> #{e.destination.name} [label=\"#{e.requirement}\"]"
+ label = edge_label ? edge_label.call(e) : e.requirement
+ dot_edges << " #{e.origin.name} -> #{e.destination.name} [label=#{label.to_s.dump}]"
end
end
+
+ dot_vertices.uniq!
dot_vertices.sort!
+ dot_edges.uniq!
dot_edges.sort!
+
dot = dot_vertices.unshift('digraph G {').push('') + dot_edges.push('}')
dot.join("\n")
end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
index a030c03f5f..9092e4d546 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
@@ -23,8 +23,8 @@ module Bundler::Molinillo
# (see Action#down)
def down(graph)
edge = make_edge(graph)
- edge.origin.outgoing_edges.delete(edge)
- edge.destination.incoming_edges.delete(edge)
+ delete_first(edge.origin.outgoing_edges, edge)
+ delete_first(edge.destination.incoming_edges, edge)
end
# @!group AddEdgeNoCircular
@@ -53,6 +53,13 @@ module Bundler::Molinillo
@destination = destination
@requirement = requirement
end
+
+ private
+
+ def delete_first(array, item)
+ return unless index = array.index(item)
+ array.delete_at(index)
+ end
end
end
end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb b/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb
index 4f5d450f59..49ab4492fb 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module Bundler::Molinillo
# The version of Bundler::Molinillo.
- VERSION = '0.5.5'.freeze
+ VERSION = '0.5.6'.freeze
end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb b/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb
index a903b21239..d47cfa2928 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb
@@ -48,7 +48,7 @@ module Bundler::Molinillo
if debug?
debug_info = yield
debug_info = debug_info.inspect unless debug_info.is_a?(String)
- output.puts debug_info.split("\n").map { |s| ' ' * depth + s }
+ output.puts debug_info.split("\n").map { |s| ' ' * depth + s }
end
end
diff --git a/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
index 9054a4ae14..02431dd869 100644
--- a/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
+++ b/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb
@@ -356,13 +356,20 @@ module Bundler::Molinillo
# Ensures there are no orphaned successors to the given {vertex}.
# @param [DependencyGraph::Vertex] vertex the vertex to fix up.
# @return [void]
- def fixup_swapped_children(vertex)
+ def fixup_swapped_children(vertex) # rubocop:disable Metrics/CyclomaticComplexity
payload = vertex.payload
deps = dependencies_for(payload).group_by(&method(:name_for))
vertex.outgoing_edges.each do |outgoing_edge|
- @parent_of[outgoing_edge.requirement] = states.size - 1
+ requirement = outgoing_edge.requirement
+ parent_index = @parent_of[requirement]
succ = outgoing_edge.destination
matching_deps = Array(deps[succ.name])
+ dep_matched = matching_deps.include?(requirement)
+
+ # only reset the parent index when it was originally required by the
+ # same named spec
+ @parent_of[requirement] = states.size - 1 if parent_index && states[parent_index].name == name
+
if matching_deps.empty? && !succ.root? && succ.predecessors.to_a == [vertex]
debug(depth) { "Removing orphaned spec #{succ.name} after swapping #{name}" }
succ.requirements.each { |r| @parent_of.delete(r) }
@@ -373,9 +380,13 @@ module Bundler::Molinillo
# so it's safe to delete only based upon name here
removed_names.include?(name_for(r))
end
- elsif !matching_deps.include?(outgoing_edge.requirement)
+ elsif !dep_matched
+ # also reset if we're removing the edge, but only if its parent has
+ # already been fixed up
+ @parent_of[requirement] = states.size - 1 if @parent_of[requirement].nil?
+
activated.delete_edge(outgoing_edge)
- requirements.delete(outgoing_edge.requirement)
+ requirements.delete(requirement)
end
end
end