Previously `cargo update foo` would only update the package `foo` if it were a
direct dependency of the local package. This meant that to update a transitive
dependency you would have to update the top-level dependency.
This commit adds the ability to update any dependency by name, regardless of
where it is in the dependency graph. This commit is a bit lossy in terms of
behavior. We are guaranteed that the set of immediate dependencies for any one
package have unique names, but not for the entire package graph. This means that
when you invoke `cargo update foo` it could possibly update two packages named
`foo`.
I believe this behavior to be acceptable for now and we can add a more stringent
update syntax later (something like `cargo update --namespace foo bar`). I
believe we'll always want this CLI usage, however.
let sources = match to_update {
Some(name) => {
let mut to_avoid = HashSet::new();
- match resolve.deps(package.get_package_id()) {
- Some(deps) => {
- for dep in deps.filter(|d| d.get_name() == name.as_slice()) {
- fill_with_deps(&resolve, dep, &mut to_avoid);
- }
- }
- None => {}
+ for dep in resolve.iter().filter(|d| d.get_name() == name.as_slice()) {
+ fill_with_deps(&resolve, dep, &mut to_avoid);
}
resolve.iter().filter(|pkgid| !to_avoid.contains(pkgid))
.map(|pkgid| pkgid.get_source_id().clone()).collect()
{compiling} foo v0.5.0 ({dir})\n",
git = git_project.url(),
compiling = COMPILING, dir = p.url())));
+
+ // We should be able to update transitive deps
+ assert_that(p.process(cargo_dir().join("cargo-update")).arg("bar"),
+ execs().with_stdout(format!("{} git repository `{}`",
+ UPDATING,
+ git_project.url())));
})
test!(dep_with_submodule {