@@ -45,7 +45,11 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
4545 Ok ( ( ) )
4646}
4747
48- pub fn update_lockfile ( ws : & Workspace < ' _ > , opts : & UpdateOptions < ' _ > ) -> CargoResult < ( ) > {
48+ pub fn update_lockfile (
49+ ws : & Workspace < ' _ > ,
50+ opts : & UpdateOptions < ' _ > ,
51+ upgrades : & HashMap < String , Version > ,
52+ ) -> CargoResult < ( ) > {
4953 if opts. recursive && opts. precise . is_some ( ) {
5054 anyhow:: bail!( "cannot specify both recursive and precise simultaneously" )
5155 }
@@ -161,7 +165,12 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
161165 . filter ( |s| !s. is_registry ( ) )
162166 . collect ( ) ;
163167
164- let keep = |p : & PackageId | !to_avoid_sources. contains ( & p. source_id ( ) ) && !to_avoid. contains ( p) ;
168+ let keep = |p : & PackageId | {
169+ ( !to_avoid_sources. contains ( & p. source_id ( ) ) && !to_avoid. contains ( p) )
170+ // In case of `--breaking`, we want to keep all packages unchanged that
171+ // didn't get upgraded.
172+ || ( opts. breaking && !upgrades. contains_key ( & p. name ( ) . to_string ( ) ) )
173+ } ;
165174
166175 let mut resolve = ops:: resolve_with_previous (
167176 & mut registry,
@@ -238,7 +247,7 @@ pub fn update_manifests(
238247 . summary ( )
239248 . clone ( )
240249 . map_dependencies ( |dependency| {
241- let req = if let OptVersionReq :: Req ( current) = dependency. version_req ( ) {
250+ if let OptVersionReq :: Req ( current) = dependency. version_req ( ) {
242251 let query = crate :: core:: dependency:: Dependency :: parse (
243252 dependency. package_name ( ) ,
244253 None ,
@@ -269,6 +278,13 @@ pub fn update_manifests(
269278
270279 if let Some ( latest) = latest. clone ( ) {
271280 if !current. matches ( & latest) {
281+ debug ! (
282+ "upgrading {} from {} to {}" ,
283+ dependency. package_name( ) ,
284+ current,
285+ latest
286+ ) ;
287+
272288 opts. gctx
273289 . shell ( )
274290 . status_with_color (
@@ -284,17 +300,17 @@ pub fn update_manifests(
284300 . unwrap ( ) ;
285301
286302 upgrades. insert ( dependency. package_name ( ) . to_string ( ) , latest. clone ( ) ) ;
303+
304+ let req =
305+ OptVersionReq :: Req ( VersionReq :: parse ( & latest. to_string ( ) ) . unwrap ( ) ) ;
306+ let mut dep = dependency. clone ( ) ;
307+ dep. set_version_req ( req) ;
308+ return dep;
287309 }
288310 }
311+ }
289312
290- OptVersionReq :: Req ( VersionReq :: parse ( & latest. unwrap ( ) . to_string ( ) ) . unwrap ( ) )
291- } else {
292- dependency. version_req ( ) . clone ( )
293- } ;
294-
295- let mut dep = dependency. clone ( ) ;
296- dep. set_version_req ( req) ;
297- dep
313+ dependency. clone ( )
298314 } ) ;
299315
300316 let summary = member. manifest_mut ( ) . summary_mut ( ) ;
0 commit comments