Skip to content

Commit

Permalink
fix(resolver): Make resolver behavior independent or package order
Browse files Browse the repository at this point in the history
This address one of the problems mentioned in #12599
  • Loading branch information
epage committed Aug 30, 2023
1 parent f87928a commit b27debc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/cargo/ops/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,15 +642,19 @@ fn register_previous_locks(
// if they changed.
let mut avoid_locking = HashSet::new();
registry.add_to_yanked_whitelist(resolve.iter().filter(keep));
// We must check `path_pkg` first so we don't recursively walk them via `add_deps`
for node in resolve.iter() {
if !keep(&node) {
add_deps(resolve, node, &mut avoid_locking);
} else if let Some(pkg) = path_pkg(node.source_id()) {
if let Some(pkg) = path_pkg(node.source_id()) {
if pkg.package_id() != node {
avoid_locking.insert(node);
}
}
}
for node in resolve.iter() {
if !keep(&node) {
add_deps(resolve, node, &mut avoid_locking);
}
}

// Ok, but the above loop isn't the entire story! Updates to the dependency
// graph can come from two locations, the `cargo update` command or
Expand Down
7 changes: 2 additions & 5 deletions tests/testsuite/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,14 +954,11 @@ rustdns.workspace = true
p.change_file("Cargo.toml", &workspace_toml.replace("2.29.8", "2.29.81"));

p.cargo("update -p rootcrate")
.with_stderr(&format!(
.with_stderr(
"\
[UPDATING] git repository `{}`
[UPDATING] rootcrate v2.29.8 ([CWD]/rootcrate) -> v2.29.81
[UPDATING] rustdns v0.5.0 ([..]) -> [..]
[UPDATING] subcrate v2.29.8 ([CWD]/subcrate) -> v2.29.81",
git_project.url(),
))
)
.run();
}

Expand Down

0 comments on commit b27debc

Please sign in to comment.