Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Show different versions of a crate separately #29

Merged
merged 2 commits into from Sep 10, 2016

Conversation

FraGag
Copy link
Contributor

@FraGag FraGag commented May 30, 2016

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.

@yo-bot
Copy link
Collaborator

yo-bot commented May 30, 2016

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.

@homu
Copy link
Collaborator

homu commented Sep 10, 2016

☔ The latest upstream changes (presumably #31) made this pull request unmergeable. Please resolve the merge conflicts.

@kbknapp
Copy link
Owner

kbknapp commented Sep 10, 2016

@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.
@FraGag
Copy link
Contributor Author

FraGag commented Sep 10, 2016

@kbknapp Rebased.

@kbknapp
Copy link
Owner

kbknapp commented Sep 10, 2016

@homu r+

@homu
Copy link
Collaborator

homu commented Sep 10, 2016

📌 Commit d6d4a39 has been approved by kbknapp

@homu homu merged commit d6d4a39 into kbknapp:master Sep 10, 2016
homu added a commit that referenced this pull request Sep 10, 2016
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.
@homu
Copy link
Collaborator

homu commented Sep 10, 2016

⚡ Test exempted - status

@FraGag FraGag deleted the multiple-versions branch September 10, 2016 15:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show multiple instances of the same crate separately Not deterministic
4 participants