@@ -2130,30 +2130,28 @@ function why(ctx::Context, pkgs::Vector{PackageSpec}; io::IO, kwargs...)
21302130
21312131 function find_paths! (final_paths, current, path = UUID[])
21322132 push! (path, current)
2133- if ! (current in values (ctx. env. project. deps))
2134- for p in incoming[current]
2135- if p in path
2136- # detected dependency cycle and none of the dependencies in the cycle
2137- # are in the project could happen when manually modifying
2138- # the project and running this function function before a
2139- # resolve
2140- continue
2141- end
2142- find_paths! (final_paths, p, copy (path))
2133+ current in values (ctx. env. project. deps) && push! (final_paths, path) # record once we've traversed to a project dep
2134+ haskey (incoming, current) || return # but only return if we've reached a leaf that nothing depends on
2135+ for p in incoming[current]
2136+ if p in path
2137+ # detected dependency cycle and none of the dependencies in the cycle
2138+ # are in the project could happen when manually modifying
2139+ # the project and running this function function before a
2140+ # resolve
2141+ continue
21432142 end
2144- else
2145- push! (final_paths, path)
2143+ find_paths! (final_paths, p, copy (path))
21462144 end
21472145 end
21482146
21492147 first = true
21502148 for pkg in pkgs
21512149 ! first && println (io)
21522150 first = false
2153- final_paths = []
2151+ final_paths = Set {Vector{UUID}} ()
21542152 find_paths! (final_paths, pkg. uuid)
21552153 foreach (reverse!, final_paths)
2156- final_paths_names = map (x -> [ctx. env. manifest[uuid]. name for uuid in x], final_paths)
2154+ final_paths_names = map (x -> [ctx. env. manifest[uuid]. name for uuid in x], collect ( final_paths) )
21572155 sort! (final_paths_names, by = x -> (x, length (x)))
21582156 delimiter = sprint ((io, args) -> printstyled (io, args... ; color= :light_green ), " →" , context= io)
21592157 for path in final_paths_names
0 commit comments