@@ -37,7 +37,7 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
37
37
true ,
38
38
) ?;
39
39
ops:: write_pkg_lockfile ( ws, & mut resolve) ?;
40
- print_lockfile_changes ( ws. gctx ( ) , previous_resolve, & resolve, & mut registry) ?;
40
+ print_lockfile_changes ( ws, previous_resolve, & resolve, & mut registry) ?;
41
41
Ok ( ( ) )
42
42
}
43
43
@@ -170,7 +170,7 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
170
170
true ,
171
171
) ?;
172
172
173
- print_lockfile_updates ( opts . gctx , & previous_resolve, & resolve, & mut registry) ?;
173
+ print_lockfile_updates ( ws , & previous_resolve, & resolve, & mut registry) ?;
174
174
if opts. dry_run {
175
175
opts. gctx
176
176
. shell ( )
@@ -186,21 +186,23 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
186
186
/// This would acquire the package-cache lock, as it may update the index to
187
187
/// show users latest available versions.
188
188
pub fn print_lockfile_changes (
189
- gctx : & GlobalContext ,
189
+ ws : & Workspace < ' _ > ,
190
190
previous_resolve : Option < & Resolve > ,
191
191
resolve : & Resolve ,
192
192
registry : & mut PackageRegistry < ' _ > ,
193
193
) -> CargoResult < ( ) > {
194
- let _lock = gctx. acquire_package_cache_lock ( CacheLockMode :: DownloadExclusive ) ?;
194
+ let _lock = ws
195
+ . gctx ( )
196
+ . acquire_package_cache_lock ( CacheLockMode :: DownloadExclusive ) ?;
195
197
if let Some ( previous_resolve) = previous_resolve {
196
- print_lockfile_sync ( gctx , previous_resolve, resolve, registry)
198
+ print_lockfile_sync ( ws , previous_resolve, resolve, registry)
197
199
} else {
198
- print_lockfile_generation ( gctx , resolve, registry)
200
+ print_lockfile_generation ( ws , resolve, registry)
199
201
}
200
202
}
201
203
202
204
fn print_lockfile_generation (
203
- gctx : & GlobalContext ,
205
+ ws : & Workspace < ' _ > ,
204
206
resolve : & Resolve ,
205
207
registry : & mut PackageRegistry < ' _ > ,
206
208
) -> CargoResult < ( ) > {
@@ -210,7 +212,8 @@ fn print_lockfile_generation(
210
212
// just ourself, nothing worth reporting
211
213
return Ok ( ( ) ) ;
212
214
}
213
- gctx. shell ( )
215
+ ws. gctx ( )
216
+ . shell ( )
214
217
. status ( "Locking" , format ! ( "{num_pkgs} packages" ) ) ?;
215
218
216
219
for diff in diff {
@@ -245,7 +248,7 @@ fn print_lockfile_generation(
245
248
} ;
246
249
247
250
if let Some ( latest) = latest {
248
- gctx. shell ( ) . status_with_color (
251
+ ws . gctx ( ) . shell ( ) . status_with_color (
249
252
"Adding" ,
250
253
format ! ( "{package}{latest}" ) ,
251
254
& style:: NOTE ,
@@ -258,7 +261,7 @@ fn print_lockfile_generation(
258
261
}
259
262
260
263
fn print_lockfile_sync (
261
- gctx : & GlobalContext ,
264
+ ws : & Workspace < ' _ > ,
262
265
previous_resolve : & Resolve ,
263
266
resolve : & Resolve ,
264
267
registry : & mut PackageRegistry < ' _ > ,
@@ -269,7 +272,8 @@ fn print_lockfile_sync(
269
272
return Ok ( ( ) ) ;
270
273
}
271
274
let plural = if num_pkgs == 1 { "" } else { "s" } ;
272
- gctx. shell ( )
275
+ ws. gctx ( )
276
+ . shell ( )
273
277
. status ( "Locking" , format ! ( "{num_pkgs} package{plural}" ) ) ?;
274
278
275
279
for diff in diff {
@@ -318,10 +322,12 @@ fn print_lockfile_sync(
318
322
// This metadata is often stuff like git commit hashes, which are
319
323
// not meaningfully ordered.
320
324
if removed. version ( ) . cmp_precedence ( added. version ( ) ) == Ordering :: Greater {
321
- gctx. shell ( )
325
+ ws. gctx ( )
326
+ . shell ( )
322
327
. status_with_color ( "Downgrading" , msg, & style:: WARN ) ?;
323
328
} else {
324
- gctx. shell ( )
329
+ ws. gctx ( )
330
+ . shell ( )
325
331
. status_with_color ( "Updating" , msg, & style:: GOOD ) ?;
326
332
}
327
333
} else {
@@ -339,7 +345,7 @@ fn print_lockfile_sync(
339
345
}
340
346
. unwrap_or_default ( ) ;
341
347
342
- gctx. shell ( ) . status_with_color (
348
+ ws . gctx ( ) . shell ( ) . status_with_color (
343
349
"Adding" ,
344
350
format ! ( "{package}{latest}" ) ,
345
351
& style:: NOTE ,
@@ -352,7 +358,7 @@ fn print_lockfile_sync(
352
358
}
353
359
354
360
fn print_lockfile_updates (
355
- gctx : & GlobalContext ,
361
+ ws : & Workspace < ' _ > ,
356
362
previous_resolve : & Resolve ,
357
363
resolve : & Resolve ,
358
364
registry : & mut PackageRegistry < ' _ > ,
@@ -404,16 +410,21 @@ fn print_lockfile_updates(
404
410
// This metadata is often stuff like git commit hashes, which are
405
411
// not meaningfully ordered.
406
412
if removed. version ( ) . cmp_precedence ( added. version ( ) ) == Ordering :: Greater {
407
- gctx. shell ( )
413
+ ws. gctx ( )
414
+ . shell ( )
408
415
. status_with_color ( "Downgrading" , msg, & style:: WARN ) ?;
409
416
} else {
410
- gctx. shell ( )
417
+ ws. gctx ( )
418
+ . shell ( )
411
419
. status_with_color ( "Updating" , msg, & style:: GOOD ) ?;
412
420
}
413
421
} else {
414
422
for package in diff. removed . iter ( ) {
415
- gctx. shell ( )
416
- . status_with_color ( "Removing" , format ! ( "{package}" ) , & style:: ERROR ) ?;
423
+ ws. gctx ( ) . shell ( ) . status_with_color (
424
+ "Removing" ,
425
+ format ! ( "{package}" ) ,
426
+ & style:: ERROR ,
427
+ ) ?;
417
428
}
418
429
for package in diff. added . iter ( ) {
419
430
let latest = if !possibilities. is_empty ( ) {
@@ -429,7 +440,7 @@ fn print_lockfile_updates(
429
440
}
430
441
. unwrap_or_default ( ) ;
431
442
432
- gctx. shell ( ) . status_with_color (
443
+ ws . gctx ( ) . shell ( ) . status_with_color (
433
444
"Adding" ,
434
445
format ! ( "{package}{latest}" ) ,
435
446
& style:: NOTE ,
@@ -451,8 +462,8 @@ fn print_lockfile_updates(
451
462
452
463
if let Some ( latest) = latest {
453
464
unchanged_behind += 1 ;
454
- if gctx. shell ( ) . verbosity ( ) == Verbosity :: Verbose {
455
- gctx. shell ( ) . status_with_color (
465
+ if ws . gctx ( ) . shell ( ) . verbosity ( ) == Verbosity :: Verbose {
466
+ ws . gctx ( ) . shell ( ) . status_with_color (
456
467
"Unchanged" ,
457
468
format ! ( "{package}{latest}" ) ,
458
469
& anstyle:: Style :: new ( ) . bold ( ) ,
@@ -462,13 +473,13 @@ fn print_lockfile_updates(
462
473
}
463
474
}
464
475
465
- if gctx. shell ( ) . verbosity ( ) == Verbosity :: Verbose {
466
- gctx. shell ( ) . note (
476
+ if ws . gctx ( ) . shell ( ) . verbosity ( ) == Verbosity :: Verbose {
477
+ ws . gctx ( ) . shell ( ) . note (
467
478
"to see how you depend on a package, run `cargo tree --invert --package <dep>@<ver>`" ,
468
479
) ?;
469
480
} else {
470
481
if 0 < unchanged_behind {
471
- gctx. shell ( ) . note ( format ! (
482
+ ws . gctx ( ) . shell ( ) . note ( format ! (
472
483
"pass `--verbose` to see {unchanged_behind} unchanged dependencies behind latest"
473
484
) ) ?;
474
485
}
0 commit comments