Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate duplicate entries with a (*) #33

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jamessan
Copy link
Contributor

Rather than re-traverse the entries, which can lead to pathological cases of recursion, keep track of which PackageIds have been shown. When encountering a duplicate PackageId, indicate this with "(*)" as "cargo tree" does, and return early.

Rather than re-traverse the entries, which can lead to [pathological
cases] of recursion, keep track of which PackageIds have been shown.
When encountering a duplicate PackageId, indicate this with "(*)" as
"cargo tree" does, and return early.

[pathological cases]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1052650
@jamessan
Copy link
Contributor Author

This doesn't address the pathological case if -a is used, though. That would likely require taking into account the feature's depended on, like cargo tree does. The reason we get into trouble is that we just consider the package (independent of feature), so there are loops.

@kpcyrd
Copy link
Owner

kpcyrd commented Nov 29, 2023

I think I'd prefer this feature opt-in instead of opt-out, not removing duplicates was intentional because it often makes the output easier to work with - especially with large dependency trees and many missing packages it's very difficult to track down the (*) references, and expanding them gives you a better idea of "how many levels" are missing.

I've investigated this and it's because the way the ruff repository uses [dev-dependencies] is causing cycles. Since debian needs the dev-dependencies to package a crate, these are considered by cargo-debstatus, but cargo will only consider the [dev-dependencies] of the specific crate you want to build (but not the [dev-dependencies] of any dependencies), so it doesn't consider this a cycle. cargo-debstatus doesn't consider disabled features so there are no other cycles (problems with expanding features is documented in #2).

Maybe we could keep track of the current path with a hashset and as soon as there truly is a cycle (like with ruff) we could detect this because .insert would return false and we could stop traversing at then.

@jamessan jamessan marked this pull request as draft December 6, 2023 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants