@@ -2154,30 +2154,28 @@ function why(ctx::Context, pkgs::Vector{PackageSpec}; io::IO, kwargs...)
21542154
21552155 function find_paths! (final_paths, current, path = UUID[])
21562156 push! (path, current)
2157- if ! (current in values (ctx. env. project. deps))
2158- for p in incoming[current]
2159- if p in path
2160- # detected dependency cycle and none of the dependencies in the cycle
2161- # are in the project could happen when manually modifying
2162- # the project and running this function function before a
2163- # resolve
2164- continue
2165- end
2166- find_paths! (final_paths, p, copy (path))
2157+ current in values (ctx. env. project. deps) && push! (final_paths, path) # record once we've traversed to a project dep
2158+ haskey (incoming, current) || return # but only return if we've reached a leaf that nothing depends on
2159+ for p in incoming[current]
2160+ if p in path
2161+ # detected dependency cycle and none of the dependencies in the cycle
2162+ # are in the project could happen when manually modifying
2163+ # the project and running this function function before a
2164+ # resolve
2165+ continue
21672166 end
2168- else
2169- push! (final_paths, path)
2167+ find_paths! (final_paths, p, copy (path))
21702168 end
21712169 end
21722170
21732171 first = true
21742172 for pkg in pkgs
21752173 ! first && println (io)
21762174 first = false
2177- final_paths = []
2175+ final_paths = Set {Vector{UUID}} ()
21782176 find_paths! (final_paths, pkg. uuid)
21792177 foreach (reverse!, final_paths)
2180- final_paths_names = map (x -> [ctx. env. manifest[uuid]. name for uuid in x], final_paths)
2178+ final_paths_names = map (x -> [ctx. env. manifest[uuid]. name for uuid in x], collect ( final_paths) )
21812179 sort! (final_paths_names, by = x -> (x, length (x)))
21822180 delimiter = sprint ((io, args) -> printstyled (io, args... ; color= :light_green ), " →" , context= io)
21832181 for path in final_paths_names
0 commit comments