diff --git a/src/cargo/ops/cargo_generate_lockfile.rs b/src/cargo/ops/cargo_generate_lockfile.rs index b8561b1d8d4..fc22608e8f2 100644 --- a/src/cargo/ops/cargo_generate_lockfile.rs +++ b/src/cargo/ops/cargo_generate_lockfile.rs @@ -170,7 +170,13 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes true, )?; - print_lockfile_updates(ws, &previous_resolve, &resolve, &mut registry)?; + print_lockfile_updates( + ws, + &previous_resolve, + &resolve, + opts.precise.is_some(), + &mut registry, + )?; if opts.dry_run { opts.gctx .shell() @@ -356,10 +362,17 @@ fn print_lockfile_updates( ws: &Workspace<'_>, previous_resolve: &Resolve, resolve: &Resolve, + precise: bool, registry: &mut PackageRegistry<'_>, ) -> CargoResult<()> { + let diff = PackageDiff::diff(&previous_resolve, &resolve); + let num_pkgs: usize = diff.iter().map(|d| d.added.len()).sum(); + if !precise { + status_locking(ws, num_pkgs)?; + } + let mut unchanged_behind = 0; - for diff in PackageDiff::diff(&previous_resolve, &resolve) { + for diff in diff { fn format_latest(version: semver::Version) -> String { let warn = style::WARN; format!(" {warn}(latest: v{version}){warn:#}") diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs index 137c95ba116..e04fb1bddf9 100644 --- a/tests/testsuite/artifact_dep.rs +++ b/tests/testsuite/artifact_dep.rs @@ -1590,6 +1590,7 @@ fn index_version_filtering() { .with_stderr( "\ [UPDATING] [..] +[LOCKING] 2 packages to latest compatible versions [ADDING] artifact v1.0.0 [UPDATING] bar v1.0.0 -> v1.0.1", ) diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index c587585344c..32cf02b0d7f 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -616,7 +616,10 @@ fn recompilation() { p.cargo("update") .with_stderr(&format!( - "[UPDATING] git repository `{}`", + "\ +[UPDATING] git repository `{}` +[LOCKING] 0 packages to latest compatible versions +", git_project.url() )) .run(); @@ -636,9 +639,11 @@ fn recompilation() { // Update the dependency and carry on! p.cargo("update") .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [UPDATING] bar v0.5.0 ([..]) -> #[..]\n\ - ", + "\ +[UPDATING] git repository `{}` +[LOCKING] 1 package to latest compatible version +[UPDATING] bar v0.5.0 ([..]) -> #[..] +", git_project.url() )) .run(); @@ -766,6 +771,7 @@ fn update_with_shared_deps() { .with_stderr( "\ [UPDATING] git repository [..] +[LOCKING] 1 package to latest compatible version [UPDATING] bar v0.5.0 [..] ", ) @@ -791,16 +797,21 @@ Caused by: println!("bar precise update"); p.cargo("update bar --precise") .arg(&old_head.to_string()) - .with_stderr("[UPDATING] bar v0.5.0 [..]") + .with_stderr( + "\ +[UPDATING] bar v0.5.0 [..]", + ) .run(); // Updating recursively should, however, update the repo. println!("dep1 recursive update"); p.cargo("update dep1 --recursive") .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [UPDATING] bar v0.5.0 ([..]) -> #[..]\n\ - ", + "\ +[UPDATING] git repository `{}` +[LOCKING] 1 package to latest compatible version +[UPDATING] bar v0.5.0 ([..]) -> #[..] +", git_project.url() )) .run(); @@ -822,7 +833,10 @@ Caused by: // We should be able to update transitive deps p.cargo("update bar") .with_stderr(&format!( - "[UPDATING] git repository `{}`", + "\ +[UPDATING] git repository `{}` +[LOCKING] 0 packages to latest compatible versions +", git_project.url() )) .run(); @@ -1223,9 +1237,11 @@ fn two_deps_only_update_one() { p.cargo("update dep1") .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\ - ", + "\ +[UPDATING] git repository `{}` +[LOCKING] 1 package to latest compatible version +[UPDATING] dep1 v0.5.0 ([..]) -> #[..] +", git1.url() )) .run(); @@ -1411,10 +1427,12 @@ fn dep_with_changed_submodule() { p.cargo("update") .with_stderr("") .with_stderr(&format!( - "[UPDATING] git repository `{}`\n\ - [UPDATING] git submodule `file://[..]/dep3`\n\ - [UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\ - ", + "\ +[UPDATING] git repository `{}` +[UPDATING] git submodule `file://[..]/dep3` +[LOCKING] 1 package to latest compatible version +[UPDATING] dep1 v0.5.0 ([..]) -> #[..] +", git_project.url() )) .run(); @@ -1993,7 +2011,13 @@ fn update_one_dep_in_repo_with_many_deps() { p.cargo("generate-lockfile").run(); p.cargo("update bar") - .with_stderr(&format!("[UPDATING] git repository `{}`", bar.url())) + .with_stderr(&format!( + "\ +[UPDATING] git repository `{}` +[LOCKING] 0 packages to latest compatible versions +", + bar.url() + )) .run(); } diff --git a/tests/testsuite/global_cache_tracker.rs b/tests/testsuite/global_cache_tracker.rs index a7e5407af58..d3f087d72d5 100644 --- a/tests/testsuite/global_cache_tracker.rs +++ b/tests/testsuite/global_cache_tracker.rs @@ -1481,6 +1481,7 @@ fn clean_max_git_age() { .with_stderr( "\ [UPDATING] git repository [..] +[LOCKING] 1 package to latest compatible version [UPDATING] git_a v1.0.0 [..] ", ) @@ -1562,6 +1563,7 @@ fn clean_max_src_crate_age() { .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 1 package to latest compatible version [UPDATING] bar v1.0.0 -> v1.0.1 ", ) diff --git a/tests/testsuite/local_registry.rs b/tests/testsuite/local_registry.rs index 20d8a62109f..b5146863b51 100644 --- a/tests/testsuite/local_registry.rs +++ b/tests/testsuite/local_registry.rs @@ -190,7 +190,11 @@ fn multiple_versions() { .publish(); p.cargo("update") - .with_stderr("[UPDATING] bar v0.1.0 -> v0.2.0") + .with_stderr( + "\ +[LOCKING] 1 package to latest compatible version +[UPDATING] bar v0.1.0 -> v0.2.0", + ) .run(); } diff --git a/tests/testsuite/offline.rs b/tests/testsuite/offline.rs index 1875ac43d17..8e6d4e19362 100644 --- a/tests/testsuite/offline.rs +++ b/tests/testsuite/offline.rs @@ -725,6 +725,7 @@ fn main(){ .with_status(0) .with_stderr( "\ +[LOCKING] 1 package to latest compatible version [UPDATING] present_dep v1.2.3 -> v1.2.9 ", ) diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index c469f321896..f1fc5600fb9 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -2061,6 +2061,7 @@ fn update_unused_new_version() { .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 1 package to latest compatible version [ADDING] bar v0.1.6 ([..]/bar) [REMOVING] bar v0.1.5 ", @@ -2073,6 +2074,7 @@ fn update_unused_new_version() { .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 1 package to latest compatible version [ADDING] bar v0.1.6 ([..]/bar) [REMOVING] bar v0.1.5 ", @@ -2542,6 +2544,7 @@ fn can_update_with_alt_reg() { "\ [UPDATING] `alternative` index [UPDATING] `dummy-registry` index +[LOCKING] 0 packages to latest compatible versions [NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest ", ) diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index 8286d9a1e3a..24c253c5504 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -833,6 +833,7 @@ required by package `foo v0.0.1 ([..])` .with_stderr_contains( "\ [UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version [UPDATING] baz v0.0.1 -> v0.0.2 ", ) @@ -1018,6 +1019,7 @@ fn update_lockfile() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version [UPDATING] bar v0.0.2 -> v0.0.3 ", ) @@ -1043,6 +1045,7 @@ fn update_lockfile() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 2 packages to latest compatible versions [UPDATING] bar v0.0.3 -> v0.0.4 [ADDING] spam v0.2.5 ", @@ -1055,6 +1058,7 @@ fn update_lockfile() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version [UPDATING] bar v0.0.4 -> v0.0.5 [REMOVING] spam v0.2.5 ", @@ -1493,6 +1497,7 @@ fn update_transitive_dependency() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version [UPDATING] b v0.1.0 -> v0.1.1 ", ) @@ -1565,6 +1570,7 @@ fn update_backtracking_ok() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 2 packages to latest compatible versions [UPDATING] hyper v0.6.5 -> v0.6.6 [UPDATING] openssl v0.1.0 -> v0.1.1 ", @@ -1617,6 +1623,7 @@ fn update_multiple_packages() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 2 packages to latest compatible versions [UPDATING] a v0.1.0 -> v0.1.1 [UPDATING] b v0.1.0 -> v0.1.1 [NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest @@ -1628,6 +1635,7 @@ fn update_multiple_packages() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version [UPDATING] c v0.1.0 -> v0.1.1 ", ) diff --git a/tests/testsuite/replace.rs b/tests/testsuite/replace.rs index 7d493fb1700..81b6c379489 100644 --- a/tests/testsuite/replace.rs +++ b/tests/testsuite/replace.rs @@ -560,6 +560,7 @@ fn override_adds_some_deps() { "\ [UPDATING] git repository `file://[..]` [UPDATING] `dummy-registry` index +[LOCKING] 0 packages to latest compatible versions [NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest ", ) @@ -568,6 +569,7 @@ fn override_adds_some_deps() { .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 0 packages to latest compatible versions [NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest ", ) @@ -901,6 +903,7 @@ fn update() { "\ [UPDATING] `[..]` index [UPDATING] git repository `[..]` +[LOCKING] 0 packages to latest compatible versions ", ) .run(); diff --git a/tests/testsuite/rust_version.rs b/tests/testsuite/rust_version.rs index 7e2cc8ed488..83695507983 100644 --- a/tests/testsuite/rust_version.rs +++ b/tests/testsuite/rust_version.rs @@ -670,6 +670,7 @@ See https://github.com/rust-lang/cargo/issues/9930 for more information about th .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 1 package to latest compatible version [UPDATING] bar v1.5.0 -> v1.6.0 ", ) diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index 6eea809867d..2c72ae341b4 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -114,6 +114,7 @@ fn transitive_minor_update() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 0 packages to latest compatible versions [NOTE] pass `--verbose` to see 2 unchanged dependencies behind latest ", ) @@ -167,6 +168,7 @@ fn conservative() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version [UPDATING] serde v0.1.0 -> v0.1.1 [NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest ", @@ -579,6 +581,7 @@ fn update_recursive() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 2 packages to latest compatible versions [UPDATING] log v0.1.0 -> v0.1.1 [UPDATING] serde v0.2.1 -> v0.2.2 ", @@ -617,6 +620,7 @@ fn update_aggressive_alias_for_recursive() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 2 packages to latest compatible versions [UPDATING] log v0.1.0 -> v0.1.1 [UPDATING] serde v0.2.1 -> v0.2.2 ", @@ -926,6 +930,7 @@ fn dry_run_update() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version [UPDATING] serde v0.1.0 -> v0.1.1 [NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest [WARNING] not updating lockfile due to dry run @@ -1126,6 +1131,7 @@ rustdns.workspace = true p.cargo("update -p rootcrate") .with_stderr(&format!( "\ +[LOCKING] 2 packages to latest compatible versions [UPDATING] rootcrate v2.29.8 ([CWD]/rootcrate) -> v2.29.81 [UPDATING] subcrate v2.29.8 ([CWD]/subcrate) -> v2.29.81", )) @@ -1217,6 +1223,7 @@ rustdns.workspace = true p.cargo("update -p crate2") .with_stderr(&format!( "\ +[LOCKING] 2 packages to latest compatible versions [UPDATING] crate1 v2.29.8 ([CWD]/crate1) -> v2.29.81 [UPDATING] crate2 v2.29.8 ([CWD]/crate2) -> v2.29.81", )) @@ -1308,6 +1315,7 @@ rustdns.workspace = true p.cargo("update --workspace") .with_stderr( "\ +[LOCKING] 2 packages to latest compatible versions [UPDATING] crate1 v2.29.8 ([CWD]/crate1) -> v2.29.81 [UPDATING] crate2 v2.29.8 ([CWD]/crate2) -> v2.29.81", ) @@ -1553,6 +1561,7 @@ fn report_behind() { .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 1 package to latest compatible version [UPDATING] breaking v0.1.0 -> v0.1.1 (latest: v0.2.0) [NOTE] pass `--verbose` to see 2 unchanged dependencies behind latest [WARNING] not updating lockfile due to dry run @@ -1564,6 +1573,7 @@ fn report_behind() { .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 1 package to latest compatible version [UPDATING] breaking v0.1.0 -> v0.1.1 (latest: v0.2.0) [UNCHANGED] pre v1.0.0-alpha.0 (latest: v1.0.0-alpha.1) [UNCHANGED] two-ver v0.1.0 (latest: v0.2.0) @@ -1579,6 +1589,7 @@ fn report_behind() { .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 0 packages to latest compatible versions [NOTE] pass `--verbose` to see 3 unchanged dependencies behind latest [WARNING] not updating lockfile due to dry run ", @@ -1589,6 +1600,7 @@ fn report_behind() { .with_stderr( "\ [UPDATING] `dummy-registry` index +[LOCKING] 0 packages to latest compatible versions [UNCHANGED] breaking v0.1.1 (latest: v0.2.0) [UNCHANGED] pre v1.0.0-alpha.0 (latest: v1.0.0-alpha.1) [UNCHANGED] two-ver v0.1.0 (latest: v0.2.0) @@ -1629,6 +1641,7 @@ fn update_with_missing_feature() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 0 packages to latest compatible versions [NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest ", ) @@ -1640,6 +1653,7 @@ fn update_with_missing_feature() { .with_stderr( "\ [UPDATING] `[..]` index +[LOCKING] 1 package to latest compatible version [UPDATING] bar v0.1.0 -> v0.1.2 ", )