breadth-first search for dependents upgrade

Fixes Homebrew/brew#6386
This commit is contained in:
L. E. Segovia 2019-08-22 12:38:28 +00:00
parent a72ea8baa0
commit efb200e825
No known key found for this signature in database
GPG Key ID: D5D1DC48B52B7AD5

View File

@ -213,9 +213,15 @@ module Homebrew
formulae_to_upgrade = Set.new
formulae_pinned = Set.new
formulae.each do |formula|
formulae_to_check = formulae
checked_formulae = Set.new
until formulae_to_check.empty?
descendants = Set.new
formulae_to_check.each do |formula|
next if checked_formulae.include?(formula)
dependents = kegs.select do |keg|
keg.runtime_dependencies
.any? { |d| d["full_name"] == formula.full_name }
@ -228,7 +234,6 @@ module Homebrew
dependent_formulae.each do |f|
next if formulae_to_upgrade.include?(f)
next if formulae_pinned.include?(f)
if f.outdated?(fetch_head: args.fetch_HEAD?)
if f.pinned?
formulae_pinned << f
@ -240,10 +245,10 @@ module Homebrew
descendants << f
end
upgradable_descendants, pinned_descendants = upgradable_dependents(kegs, descendants)
checked_formulae << formula
end
formulae_to_upgrade.merge upgradable_descendants
formulae_pinned.merge pinned_descendants
formulae_to_check = descendants
end
[formulae_to_upgrade, formulae_pinned]