зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Bump Molinillo and tsort
And configure tsort to be vendored as a dependency of Molinillo. https://github.com/rubygems/rubygems/commit/8ec749f891
This commit is contained in:
Родитель
9477ec732b
Коммит
d82328ffc8
|
@ -32,7 +32,7 @@ module Gem::Resolver::Molinillo
|
|||
# all belong to the same graph.
|
||||
# @return [Array<Vertex>] The sorted vertices.
|
||||
def self.tsort(vertices)
|
||||
TSort.tsort(
|
||||
Gem::TSort.tsort(
|
||||
lambda { |b| vertices.each(&b) },
|
||||
lambda { |v, &b| (v.successors & vertices).each(&b) }
|
||||
)
|
||||
|
|
|
@ -107,8 +107,9 @@ module Gem::Resolver::Molinillo
|
|||
end
|
||||
end
|
||||
|
||||
conflicts.sort.reduce(''.dup) do |o, (name, conflict)|
|
||||
o << "\n" << incompatible_version_message_for_conflict.call(name, conflict) << "\n"
|
||||
full_message_for_conflict = opts.delete(:full_message_for_conflict) do
|
||||
proc do |name, conflict|
|
||||
o = "\n".dup << incompatible_version_message_for_conflict.call(name, conflict) << "\n"
|
||||
if conflict.locked_requirement
|
||||
o << %( In snapshot (#{name_for_locking_dependency_source}):\n)
|
||||
o << %( #{printable_requirement.call(conflict.locked_requirement)}\n)
|
||||
|
@ -137,6 +138,11 @@ module Gem::Resolver::Molinillo
|
|||
additional_message_for_conflict.call(o, name, conflict)
|
||||
|
||||
o
|
||||
end
|
||||
end
|
||||
|
||||
conflicts.sort.reduce(''.dup) do |o, (name, conflict)|
|
||||
o << full_message_for_conflict.call(name, conflict)
|
||||
end.strip
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
module Gem::Resolver::Molinillo
|
||||
# The version of Gem::Resolver::Molinillo.
|
||||
VERSION = '0.7.0'.freeze
|
||||
VERSION = '0.8.0'.freeze
|
||||
end
|
||||
|
|
|
@ -121,8 +121,7 @@
|
|||
# <em>SIAM Journal on Computing</em>, Vol. 1, No. 2, pp. 146-160, June 1972.
|
||||
#
|
||||
|
||||
module Gem
|
||||
module TSort
|
||||
module Gem::TSort
|
||||
class Cyclic < StandardError
|
||||
end
|
||||
|
||||
|
@ -173,8 +172,8 @@ module Gem
|
|||
# each_child = lambda {|n, &b| g[n].each(&b) }
|
||||
# p Gem::TSort.tsort(each_node, each_child) # raises Gem::TSort::Cyclic
|
||||
#
|
||||
def TSort.tsort(each_node, each_child)
|
||||
Gem::TSort.tsort_each(each_node, each_child).to_a
|
||||
def self.tsort(each_node, each_child)
|
||||
tsort_each(each_node, each_child).to_a
|
||||
end
|
||||
|
||||
# The iterator version of the #tsort method.
|
||||
|
@ -221,10 +220,10 @@ module Gem
|
|||
# # 3
|
||||
# # 1
|
||||
#
|
||||
def TSort.tsort_each(each_node, each_child) # :yields: node
|
||||
def self.tsort_each(each_node, each_child) # :yields: node
|
||||
return to_enum(__method__, each_node, each_child) unless block_given?
|
||||
|
||||
Gem::TSort.each_strongly_connected_component(each_node, each_child) {|component|
|
||||
each_strongly_connected_component(each_node, each_child) {|component|
|
||||
if component.size == 1
|
||||
yield component.first
|
||||
else
|
||||
|
@ -278,8 +277,8 @@ module Gem
|
|||
# p Gem::TSort.strongly_connected_components(each_node, each_child)
|
||||
# #=> [[4], [2, 3], [1]]
|
||||
#
|
||||
def TSort.strongly_connected_components(each_node, each_child)
|
||||
Gem::TSort.each_strongly_connected_component(each_node, each_child).to_a
|
||||
def self.strongly_connected_components(each_node, each_child)
|
||||
each_strongly_connected_component(each_node, each_child).to_a
|
||||
end
|
||||
|
||||
# The iterator version of the #strongly_connected_components method.
|
||||
|
@ -340,14 +339,14 @@ module Gem
|
|||
# # [2, 3]
|
||||
# # [1]
|
||||
#
|
||||
def TSort.each_strongly_connected_component(each_node, each_child) # :yields: nodes
|
||||
def self.each_strongly_connected_component(each_node, each_child) # :yields: nodes
|
||||
return to_enum(__method__, each_node, each_child) unless block_given?
|
||||
|
||||
id_map = {}
|
||||
stack = []
|
||||
each_node.call {|node|
|
||||
unless id_map.include? node
|
||||
Gem::TSort.each_strongly_connected_component_from(node, each_child, id_map, stack) {|c|
|
||||
each_strongly_connected_component_from(node, each_child, id_map, stack) {|c|
|
||||
yield c
|
||||
}
|
||||
end
|
||||
|
@ -406,7 +405,7 @@ module Gem
|
|||
# # [2, 3]
|
||||
# # [1]
|
||||
#
|
||||
def TSort.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) # :yields: nodes
|
||||
def self.each_strongly_connected_component_from(node, each_child, id_map={}, stack=[]) # :yields: nodes
|
||||
return to_enum(__method__, node, each_child, id_map, stack) unless block_given?
|
||||
|
||||
minimum_id = node_id = id_map[node] = id_map.size
|
||||
|
@ -419,7 +418,7 @@ module Gem
|
|||
minimum_id = child_id if child_id && child_id < minimum_id
|
||||
else
|
||||
sub_minimum_id =
|
||||
Gem::TSort.each_strongly_connected_component_from(child, each_child, id_map, stack) {|c|
|
||||
each_strongly_connected_component_from(child, each_child, id_map, stack) {|c|
|
||||
yield c
|
||||
}
|
||||
minimum_id = sub_minimum_id if sub_minimum_id < minimum_id
|
||||
|
@ -451,4 +450,3 @@ module Gem
|
|||
raise NotImplementedError.new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче