Skip to content

Commit e772fc9

Browse files
committed
feat(update): Include a Locking message
1 parent 9f8adff commit e772fc9

File tree

11 files changed

+104
-19
lines changed

11 files changed

+104
-19
lines changed

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,12 @@ fn print_lockfile_updates(
358358
resolve: &Resolve,
359359
registry: &mut PackageRegistry<'_>,
360360
) -> CargoResult<()> {
361+
let diff = PackageDiff::diff(&previous_resolve, &resolve);
362+
let num_pkgs: usize = diff.iter().map(|d| d.added.len()).sum();
363+
status_locking(ws, num_pkgs)?;
364+
361365
let mut unchanged_behind = 0;
362-
for diff in PackageDiff::diff(&previous_resolve, &resolve) {
366+
for diff in diff {
363367
fn format_latest(version: semver::Version) -> String {
364368
let warn = style::WARN;
365369
format!(" {warn}(latest: v{version}){warn:#}")

tests/testsuite/git.rs

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,10 @@ fn recompilation() {
616616

617617
p.cargo("update")
618618
.with_stderr(&format!(
619-
"[UPDATING] git repository `{}`",
619+
"\
620+
[UPDATING] git repository `{}`
621+
[LOCKING] 0 packages to latest compatible versions
622+
",
620623
git_project.url()
621624
))
622625
.run();
@@ -636,9 +639,11 @@ fn recompilation() {
636639
// Update the dependency and carry on!
637640
p.cargo("update")
638641
.with_stderr(&format!(
639-
"[UPDATING] git repository `{}`\n\
640-
[UPDATING] bar v0.5.0 ([..]) -> #[..]\n\
641-
",
642+
"\
643+
[UPDATING] git repository `{}`
644+
[LOCKING] 1 package to latest compatible version
645+
[UPDATING] bar v0.5.0 ([..]) -> #[..]
646+
",
642647
git_project.url()
643648
))
644649
.run();
@@ -766,6 +771,7 @@ fn update_with_shared_deps() {
766771
.with_stderr(
767772
"\
768773
[UPDATING] git repository [..]
774+
[LOCKING] 1 package to latest compatible version
769775
[UPDATING] bar v0.5.0 [..]
770776
",
771777
)
@@ -791,16 +797,22 @@ Caused by:
791797
println!("bar precise update");
792798
p.cargo("update bar --precise")
793799
.arg(&old_head.to_string())
794-
.with_stderr("[UPDATING] bar v0.5.0 [..]")
800+
.with_stderr(
801+
"\
802+
[LOCKING] 1 package to latest compatible version
803+
[UPDATING] bar v0.5.0 [..]",
804+
)
795805
.run();
796806

797807
// Updating recursively should, however, update the repo.
798808
println!("dep1 recursive update");
799809
p.cargo("update dep1 --recursive")
800810
.with_stderr(&format!(
801-
"[UPDATING] git repository `{}`\n\
802-
[UPDATING] bar v0.5.0 ([..]) -> #[..]\n\
803-
",
811+
"\
812+
[UPDATING] git repository `{}`
813+
[LOCKING] 1 package to latest compatible version
814+
[UPDATING] bar v0.5.0 ([..]) -> #[..]
815+
",
804816
git_project.url()
805817
))
806818
.run();
@@ -822,7 +834,10 @@ Caused by:
822834
// We should be able to update transitive deps
823835
p.cargo("update bar")
824836
.with_stderr(&format!(
825-
"[UPDATING] git repository `{}`",
837+
"\
838+
[UPDATING] git repository `{}`
839+
[LOCKING] 0 packages to latest compatible versions
840+
",
826841
git_project.url()
827842
))
828843
.run();
@@ -1223,9 +1238,11 @@ fn two_deps_only_update_one() {
12231238

12241239
p.cargo("update dep1")
12251240
.with_stderr(&format!(
1226-
"[UPDATING] git repository `{}`\n\
1227-
[UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\
1228-
",
1241+
"\
1242+
[UPDATING] git repository `{}`
1243+
[LOCKING] 1 package to latest compatible version
1244+
[UPDATING] dep1 v0.5.0 ([..]) -> #[..]
1245+
",
12291246
git1.url()
12301247
))
12311248
.run();
@@ -1411,10 +1428,12 @@ fn dep_with_changed_submodule() {
14111428
p.cargo("update")
14121429
.with_stderr("")
14131430
.with_stderr(&format!(
1414-
"[UPDATING] git repository `{}`\n\
1415-
[UPDATING] git submodule `file://[..]/dep3`\n\
1416-
[UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\
1417-
",
1431+
"\
1432+
[UPDATING] git repository `{}`
1433+
[UPDATING] git submodule `file://[..]/dep3`
1434+
[LOCKING] 1 package to latest compatible version
1435+
[UPDATING] dep1 v0.5.0 ([..]) -> #[..]
1436+
",
14181437
git_project.url()
14191438
))
14201439
.run();
@@ -1993,7 +2012,13 @@ fn update_one_dep_in_repo_with_many_deps() {
19932012

19942013
p.cargo("generate-lockfile").run();
19952014
p.cargo("update bar")
1996-
.with_stderr(&format!("[UPDATING] git repository `{}`", bar.url()))
2015+
.with_stderr(&format!(
2016+
"\
2017+
[UPDATING] git repository `{}`
2018+
[LOCKING] 0 packages to latest compatible versions
2019+
",
2020+
bar.url()
2021+
))
19972022
.run();
19982023
}
19992024

tests/testsuite/global_cache_tracker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,7 @@ fn clean_max_git_age() {
14811481
.with_stderr(
14821482
"\
14831483
[UPDATING] git repository [..]
1484+
[LOCKING] 1 package to latest compatible version
14841485
[UPDATING] git_a v1.0.0 [..]
14851486
",
14861487
)
@@ -1562,6 +1563,7 @@ fn clean_max_src_crate_age() {
15621563
.with_stderr(
15631564
"\
15641565
[UPDATING] `dummy-registry` index
1566+
[LOCKING] 1 package to latest compatible version
15651567
[UPDATING] bar v1.0.0 -> v1.0.1
15661568
",
15671569
)

tests/testsuite/local_registry.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ fn multiple_versions() {
190190
.publish();
191191

192192
p.cargo("update")
193-
.with_stderr("[UPDATING] bar v0.1.0 -> v0.2.0")
193+
.with_stderr(
194+
"\
195+
[LOCKING] 1 package to latest compatible version
196+
[UPDATING] bar v0.1.0 -> v0.2.0",
197+
)
194198
.run();
195199
}
196200

tests/testsuite/offline.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ fn main(){
702702
.with_status(0)
703703
.with_stderr(
704704
"\
705+
[LOCKING] 1 package to latest compatible version
705706
[DOWNGRADING] present_dep v1.2.9 -> v1.2.3
706707
",
707708
)
@@ -725,6 +726,7 @@ fn main(){
725726
.with_status(0)
726727
.with_stderr(
727728
"\
729+
[LOCKING] 1 package to latest compatible version
728730
[UPDATING] present_dep v1.2.3 -> v1.2.9
729731
",
730732
)

tests/testsuite/patch.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,7 @@ fn update_unused_new_version() {
20612061
.with_stderr(
20622062
"\
20632063
[UPDATING] `dummy-registry` index
2064+
[LOCKING] 1 package to latest compatible version
20642065
[ADDING] bar v0.1.6 ([..]/bar)
20652066
[REMOVING] bar v0.1.5
20662067
",
@@ -2073,6 +2074,7 @@ fn update_unused_new_version() {
20732074
.with_stderr(
20742075
"\
20752076
[UPDATING] `dummy-registry` index
2077+
[LOCKING] 1 package to latest compatible version
20762078
[ADDING] bar v0.1.6 ([..]/bar)
20772079
[REMOVING] bar v0.1.5
20782080
",
@@ -2542,6 +2544,7 @@ fn can_update_with_alt_reg() {
25422544
"\
25432545
[UPDATING] `alternative` index
25442546
[UPDATING] `dummy-registry` index
2547+
[LOCKING] 0 packages to latest compatible versions
25452548
[NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest
25462549
",
25472550
)

tests/testsuite/precise_pre_release.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ fn update_pre_release() {
6565
.masquerade_as_nightly_cargo(&["precise-pre-release"])
6666
.with_stderr(
6767
r#"[UPDATING] `dummy-registry` index
68+
[LOCKING] 1 package to latest compatible version
6869
[UPDATING] my-dependency v0.1.1 -> v0.1.2-pre.0
6970
"#,
7071
)
@@ -98,6 +99,7 @@ fn update_pre_release_differ() {
9899
.masquerade_as_nightly_cargo(&["precise-pre-release"])
99100
.with_stderr(
100101
r#"[UPDATING] `dummy-registry` index
102+
[LOCKING] 1 package to latest compatible version
101103
[DOWNGRADING] my-dependency v0.1.2 -> v0.1.2-pre.0
102104
"#,
103105
)
@@ -107,6 +109,7 @@ fn update_pre_release_differ() {
107109
.masquerade_as_nightly_cargo(&["precise-pre-release"])
108110
.with_stderr(
109111
r#"[UPDATING] `dummy-registry` index
112+
[LOCKING] 1 package to latest compatible version
110113
[UPDATING] my-dependency v0.1.2-pre.0 -> v0.1.2-pre.1
111114
"#,
112115
)

tests/testsuite/registry.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ required by package `foo v0.0.1 ([..])`
833833
.with_stderr_contains(
834834
"\
835835
[UPDATING] `[..]` index
836+
[LOCKING] 1 package to latest compatible version
836837
[UPDATING] baz v0.0.1 -> v0.0.2
837838
",
838839
)
@@ -995,6 +996,7 @@ fn update_lockfile() {
995996
.with_stderr(
996997
"\
997998
[UPDATING] `[..]` index
999+
[LOCKING] 1 package to latest compatible version
9981000
[UPDATING] bar v0.0.1 -> v0.0.2
9991001
",
10001002
)
@@ -1018,6 +1020,7 @@ fn update_lockfile() {
10181020
.with_stderr(
10191021
"\
10201022
[UPDATING] `[..]` index
1023+
[LOCKING] 1 package to latest compatible version
10211024
[UPDATING] bar v0.0.2 -> v0.0.3
10221025
",
10231026
)
@@ -1043,6 +1046,7 @@ fn update_lockfile() {
10431046
.with_stderr(
10441047
"\
10451048
[UPDATING] `[..]` index
1049+
[LOCKING] 2 packages to latest compatible versions
10461050
[UPDATING] bar v0.0.3 -> v0.0.4
10471051
[ADDING] spam v0.2.5
10481052
",
@@ -1055,6 +1059,7 @@ fn update_lockfile() {
10551059
.with_stderr(
10561060
"\
10571061
[UPDATING] `[..]` index
1062+
[LOCKING] 1 package to latest compatible version
10581063
[UPDATING] bar v0.0.4 -> v0.0.5
10591064
[REMOVING] spam v0.2.5
10601065
",
@@ -1493,6 +1498,7 @@ fn update_transitive_dependency() {
14931498
.with_stderr(
14941499
"\
14951500
[UPDATING] `[..]` index
1501+
[LOCKING] 1 package to latest compatible version
14961502
[UPDATING] b v0.1.0 -> v0.1.1
14971503
",
14981504
)
@@ -1565,6 +1571,7 @@ fn update_backtracking_ok() {
15651571
.with_stderr(
15661572
"\
15671573
[UPDATING] `[..]` index
1574+
[LOCKING] 2 packages to latest compatible versions
15681575
[UPDATING] hyper v0.6.5 -> v0.6.6
15691576
[UPDATING] openssl v0.1.0 -> v0.1.1
15701577
",
@@ -1617,6 +1624,7 @@ fn update_multiple_packages() {
16171624
.with_stderr(
16181625
"\
16191626
[UPDATING] `[..]` index
1627+
[LOCKING] 2 packages to latest compatible versions
16201628
[UPDATING] a v0.1.0 -> v0.1.1
16211629
[UPDATING] b v0.1.0 -> v0.1.1
16221630
[NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest
@@ -1628,6 +1636,7 @@ fn update_multiple_packages() {
16281636
.with_stderr(
16291637
"\
16301638
[UPDATING] `[..]` index
1639+
[LOCKING] 1 package to latest compatible version
16311640
[UPDATING] c v0.1.0 -> v0.1.1
16321641
",
16331642
)
@@ -3767,6 +3776,7 @@ fn differ_only_by_metadata_with_lockfile() {
37673776
.with_stderr(
37683777
"\
37693778
[UPDATING] [..] index
3779+
[LOCKING] 1 package to latest compatible version
37703780
[..] baz v0.0.1+c -> v0.0.1+b
37713781
",
37723782
)

tests/testsuite/replace.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ fn override_adds_some_deps() {
560560
"\
561561
[UPDATING] git repository `file://[..]`
562562
[UPDATING] `dummy-registry` index
563+
[LOCKING] 0 packages to latest compatible versions
563564
[NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest
564565
",
565566
)
@@ -568,6 +569,7 @@ fn override_adds_some_deps() {
568569
.with_stderr(
569570
"\
570571
[UPDATING] `dummy-registry` index
572+
[LOCKING] 0 packages to latest compatible versions
571573
[NOTE] pass `--verbose` to see 1 unchanged dependencies behind latest
572574
",
573575
)
@@ -901,6 +903,7 @@ fn update() {
901903
"\
902904
[UPDATING] `[..]` index
903905
[UPDATING] git repository `[..]`
906+
[LOCKING] 0 packages to latest compatible versions
904907
",
905908
)
906909
.run();

tests/testsuite/rust_version.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ See https://github.com/rust-lang/cargo/issues/9930 for more information about th
670670
.with_stderr(
671671
"\
672672
[UPDATING] `dummy-registry` index
673+
[LOCKING] 1 package to latest compatible version
673674
[UPDATING] bar v1.5.0 -> v1.6.0
674675
",
675676
)

0 commit comments

Comments
 (0)