From b4ee48852bc874df38559f681d65521cfe2d6553 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 23 Aug 2023 09:05:15 -0500 Subject: [PATCH] fix(update): Clarify meaning of --aggressive as --recursive When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo update` (with a backwards compatible alias) was referenced in #12425. --- src/bin/cargo/commands/update.rs | 5 +++-- src/cargo/ops/cargo_generate_lockfile.rs | 8 ++++---- src/doc/man/cargo-update.md | 2 +- src/doc/man/generated_txt/cargo-update.txt | 2 +- src/doc/src/commands/cargo-update.md | 2 +- src/doc/src/reference/resolver.md | 2 +- src/etc/_cargo | 1 + src/etc/cargo.bashcomp.sh | 2 +- src/etc/man/cargo-update.1 | 2 +- tests/testsuite/cargo_update/help/stdout.log | 2 +- tests/testsuite/git.rs | 4 ++-- tests/testsuite/update.rs | 10 +++++----- 12 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/bin/cargo/commands/update.rs b/src/bin/cargo/commands/update.rs index 31175ef168cb..20a5481cfaea 100644 --- a/src/bin/cargo/commands/update.rs +++ b/src/bin/cargo/commands/update.rs @@ -9,9 +9,10 @@ pub fn cli() -> Command { .arg_dry_run("Don't actually write the lockfile") .arg( flag( - "aggressive", + "recursive", "Force updating all dependencies of SPEC as well when used with -p", ) + .alias("aggressive") .conflicts_with("precise"), ) .arg( @@ -41,7 +42,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { } let update_opts = UpdateOptions { - aggressive: args.flag("aggressive"), + recursive: args.flag("recursive"), precise: args.get_one::("precise").map(String::as_str), to_update: values(args, "package"), dry_run: args.dry_run(), diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index fddf83f1998a..b684a8a5aeb9 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -14,7 +14,7 @@ pub struct UpdateOptions<'a> { pub config: &'a Config, pub to_update: Vec, pub precise: Option<&'a str>, - pub aggressive: bool, + pub recursive: bool, pub dry_run: bool, pub workspace: bool, } @@ -36,8 +36,8 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> { } pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoResult<()> { - if opts.aggressive && opts.precise.is_some() { - anyhow::bail!("cannot specify both aggressive and precise simultaneously") + if opts.recursive && opts.precise.is_some() { + anyhow::bail!("cannot specify both recursive and precise simultaneously") } if ws.members().count() == 0 { @@ -84,7 +84,7 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes let mut sources = Vec::new(); for name in opts.to_update.iter() { let dep = previous_resolve.query(name)?; - if opts.aggressive { + if opts.recursive { fill_with_deps(&previous_resolve, dep, &mut to_avoid, &mut HashSet::new()); } else { to_avoid.insert(dep); diff --git a/src/doc/man/cargo-update.md b/src/doc/man/cargo-update.md index e91606a6a096..644b2a6df52b 100644 --- a/src/doc/man/cargo-update.md +++ b/src/doc/man/cargo-update.md @@ -33,7 +33,7 @@ will remain locked at their currently recorded versions. If `-p` is not specified, all dependencies are updated. {{/option}} -{{#option "`--aggressive`" }} +{{#option "`--recursive`" }} When used with `-p`, dependencies of _spec_ are forced to update as well. Cannot be used with `--precise`. {{/option}} diff --git a/src/doc/man/generated_txt/cargo-update.txt b/src/doc/man/generated_txt/cargo-update.txt index fb662c3890fc..b72b7a679753 100644 --- a/src/doc/man/generated_txt/cargo-update.txt +++ b/src/doc/man/generated_txt/cargo-update.txt @@ -26,7 +26,7 @@ OPTIONS If -p is not specified, all dependencies are updated. - --aggressive + --recursive When used with -p, dependencies of spec are forced to update as well. Cannot be used with --precise. diff --git a/src/doc/src/commands/cargo-update.md b/src/doc/src/commands/cargo-update.md index 3cfd69282226..fdb40bc736ee 100644 --- a/src/doc/src/commands/cargo-update.md +++ b/src/doc/src/commands/cargo-update.md @@ -32,7 +32,7 @@ will remain locked at their currently recorded versions.

If -p is not specified, all dependencies are updated. -

--aggressive
+
--recursive
When used with -p, dependencies of spec are forced to update as well. Cannot be used with --precise.
diff --git a/src/doc/src/reference/resolver.md b/src/doc/src/reference/resolver.md index ffb194c5e4a7..5eb3f5996a08 100644 --- a/src/doc/src/reference/resolver.md +++ b/src/doc/src/reference/resolver.md @@ -342,7 +342,7 @@ instead. [`cargo update`] can be used to update the entries in `Cargo.lock` when new versions are published. Without any options, it will attempt to update all packages in the lock file. The `-p` flag can be used to target the update for -a specific package, and other flags such as `--aggressive` or `--precise` can +a specific package, and other flags such as `--recursive` or `--precise` can be used to control how versions are selected. [`cargo build`]: ../commands/cargo-build.md diff --git a/src/etc/_cargo b/src/etc/_cargo index 164d7679f2b6..3699466b6c83 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -342,6 +342,7 @@ _cargo() { update) _arguments -s -S $common $manifest \ '--aggressive=[force dependency update]' \ + '--recursive=[force dependency update]' \ "--dry-run[don't actually write the lockfile]" \ '(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \ '--precise=[update single dependency to precise release]:release' diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh index 33f225ebf395..23f22595b17d 100644 --- a/src/etc/cargo.bashcomp.sh +++ b/src/etc/cargo.bashcomp.sh @@ -87,7 +87,7 @@ _cargo() local opt__t="$opt__test" local opt__tree="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock --target -i --invert --prefix --no-dedupe --duplicates -d --charset -f --format -e --edges" local opt__uninstall="$opt_common $opt_lock $opt_pkg --bin --root" - local opt__update="$opt_common $opt_mani $opt_lock $opt_pkg --aggressive --precise --dry-run" + local opt__update="$opt_common $opt_mani $opt_lock $opt_pkg --aggressive --recursive --precise --dry-run" local opt__vendor="$opt_common $opt_mani $opt_lock $opt_sync --no-delete --respect-source-config --versioned-dirs" local opt__verify_project="$opt_common $opt_mani $opt_lock" local opt__version="$opt_common $opt_lock" diff --git a/src/etc/man/cargo-update.1 b/src/etc/man/cargo-update.1 index 6f697b3ab19f..758bea975740 100644 --- a/src/etc/man/cargo-update.1 +++ b/src/etc/man/cargo-update.1 @@ -29,7 +29,7 @@ will remain locked at their currently recorded versions. If \fB\-p\fR is not specified, all dependencies are updated. .RE .sp -\fB\-\-aggressive\fR +\fB\-\-recursive\fR .RS 4 When used with \fB\-p\fR, dependencies of \fIspec\fR are forced to update as well. Cannot be used with \fB\-\-precise\fR\&. diff --git a/tests/testsuite/cargo_update/help/stdout.log b/tests/testsuite/cargo_update/help/stdout.log index 6cc10915179a..930d3a7363e8 100644 --- a/tests/testsuite/cargo_update/help/stdout.log +++ b/tests/testsuite/cargo_update/help/stdout.log @@ -4,7 +4,7 @@ Usage: cargo[EXE] update [OPTIONS] Options: --dry-run Don't actually write the lockfile - --aggressive Force updating all dependencies of SPEC as well when used with -p + --recursive Force updating all dependencies of SPEC as well when used with -p --precise Update a single dependency to exactly PRECISE when used with -p -q, --quiet Do not print cargo log messages -v, --verbose... Use verbose output (-vv very verbose/build.rs output) diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index f60ee978a36e..c1a4af1143e4 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -770,8 +770,8 @@ Caused by: .run(); // Updating aggressively should, however, update the repo. - println!("dep1 aggressive update"); - p.cargo("update -p dep1 --aggressive") + println!("dep1 rcursive update"); + p.cargo("update -p dep1 --recursive") .with_stderr(&format!( "[UPDATING] git repository `{}`\n\ [UPDATING] bar v0.5.0 ([..]) -> #[..]\n\ diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index d42345355785..05d6217778d8 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -428,7 +428,7 @@ fn update_precise_do_not_force_update_deps() { } #[cargo_test] -fn update_aggressive() { +fn update_recursive() { Package::new("log", "0.1.0").publish(); Package::new("serde", "0.2.1").dep("log", "0.1").publish(); @@ -453,7 +453,7 @@ fn update_aggressive() { Package::new("log", "0.1.1").publish(); Package::new("serde", "0.2.2").dep("log", "0.1").publish(); - p.cargo("update -p serde:0.2.1 --aggressive") + p.cargo("update -p serde:0.2.1 --recursive") .with_stderr( "\ [UPDATING] `[..]` index @@ -465,7 +465,7 @@ fn update_aggressive() { } #[cargo_test] -fn update_aggressive_conflicts_with_precise() { +fn update_recursive_conflicts_with_precise() { Package::new("log", "0.1.0").publish(); Package::new("serde", "0.2.1").dep("log", "0.1").publish(); @@ -490,11 +490,11 @@ fn update_aggressive_conflicts_with_precise() { Package::new("log", "0.1.1").publish(); Package::new("serde", "0.2.2").dep("log", "0.1").publish(); - p.cargo("update -p serde:0.2.1 --precise 0.2.2 --aggressive") + p.cargo("update -p serde:0.2.1 --precise 0.2.2 --recursive") .with_status(1) .with_stderr( "\ -error: the argument '--precise ' cannot be used with '--aggressive' +error: the argument '--precise ' cannot be used with '--recursive' Usage: cargo[EXE] update --package [] --precise