Show different versions of a crate separately #29
Conversation
Thanks for the pull request, and welcome! The team is excited to review your changes, and you should hear from @kbknapp (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
☔ The latest upstream changes (presumably #31) made this pull request unmergeable. Please resolve the merge conflicts. |
@FraGag apologies that I didn't see this earlier! If you can rebase onto the latest master I can merge this. Excellent work! 👍 |
Previously, `cargo graph` would merge all versions of a crate into a single node. However, a dependency graph may include multiple versions of the same crate. It is helpful to have a graph that shows which dependencies bring in an older version of a crate. Now, instead of using only the name to identify a node in the graph, we use both the name and the version. For the project's direct dependencies, we take the version from the `[root]` table in Cargo.lock. Since Cargo.toml doesn't contain the actual version used for dependencies, we can't properly initialize the list of dependencies while parsing Cargo.toml. However, Cargo.toml contains one piece of information that isn't in Cargo.lock: the kind of dependency (build, dev or optional). Instead of using a single `Dep` struct to store the information from both sources, we now use two structs: `DeclaredDep`, which represents a dependency declared in Cargo.toml, and `ResolvedDep`, which represents a resolved dependency in Cargo.lock. The kind of dependency on a `ResolvedDep` is propagated to indirect dependencies once the whole graph has been filled. Instead of having a single kind on a `ResolvedDep`, we use a set of flags so that we assign the correct kind when an indirect dependency is used through direct dependencies with different kinds. When `--include-versions` is not passed, nodes for crates with multiple versions in the graph will show the version anyway, in order to disambiguate the nodes that would otherwise have the same text. Closes kbknapp#27. Closes kbknapp#28.
3cd192e
to
d6d4a39
Compare
@kbknapp Rebased. |
@homu r+ |
📌 Commit d6d4a39 has been approved by |
Show different versions of a crate separately Previously, `cargo graph` would merge all versions of a crate into a single node. However, a dependency graph may include multiple versions of the same crate. It is helpful to have a graph that shows which dependencies bring in an older version of a crate. Now, instead of using only the name to identify a node in the graph, we use both the name and the version. For the project's direct dependencies, we take the version from the `[root]` table in Cargo.lock. Since Cargo.toml doesn't contain the actual version used for dependencies, we can't properly initialize the list of dependencies while parsing Cargo.toml. However, Cargo.toml contains one piece of information that isn't in Cargo.lock: the kind of dependency (build, dev or optional). Instead of using a single `Dep` struct to store the information from both sources, we now use two structs: `DeclaredDep`, which represents a dependency declared in Cargo.toml, and `ResolvedDep`, which represents a resolved dependency in Cargo.lock. The kind of dependency on a `ResolvedDep` is propagated to indirect dependencies once the whole graph has been filled. Instead of having a single kind on a `ResolvedDep`, we use a set of flags so that we assign the correct kind when an indirect dependency is used through direct dependencies with different kinds. When `--include-versions` is not passed, nodes for crates with multiple versions in the graph will show the version anyway, in order to disambiguate the nodes that would otherwise have the same text. Closes #27. Closes #28.
⚡ Test exempted - status |
Previously,
cargo graph
would merge all versions of a crate into a single node. However, a dependency graph may include multiple versions of the same crate. It is helpful to have a graph that shows which dependencies bring in an older version of a crate.Now, instead of using only the name to identify a node in the graph, we use both the name and the version. For the project's direct dependencies, we take the version from the
[root]
table in Cargo.lock.Since Cargo.toml doesn't contain the actual version used for dependencies, we can't properly initialize the list of dependencies while parsing Cargo.toml. However, Cargo.toml contains one piece of information that isn't in Cargo.lock: the kind of dependency (build, dev or optional). Instead of using a single
Dep
struct to store the information from both sources, we now use two structs:DeclaredDep
, which represents a dependency declared in Cargo.toml, andResolvedDep
, which represents a resolved dependency in Cargo.lock.The kind of dependency on a
ResolvedDep
is propagated to indirect dependencies once the whole graph has been filled. Instead of having a single kind on aResolvedDep
, we use a set of flags so that we assign the correct kind when an indirect dependency is used through direct dependencies with different kinds.When
--include-versions
is not passed, nodes for crates with multiple versions in the graph will show the version anyway, in order to disambiguate the nodes that would otherwise have the same text.Closes #27. Closes #28.