Skip to content

Commit

Permalink
Small fix for 'autoremove'
Browse files Browse the repository at this point in the history
Follows from ocaml#4969 and fixes ocaml#4727
  • Loading branch information
AltGr committed Jan 17, 2022
1 parent 0ac4500 commit 17b6cb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ users)
## Remove
*
* Fix message when running `opam remove` on an unavailable package [@AltGr - fix #4890]
* Fix removal of root packages with `-a` and an optional dependency explicitely specified [@AltGr - fix #4727]

## Switch
* Put back support for switch creation with packages argument and
Expand Down
20 changes: 10 additions & 10 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1172,12 +1172,8 @@ let remove_t ?ask ~autoremove ~force atoms t =
let requested = OpamPackage.names_of_packages packages in
let to_remove =
if autoremove then
let remove_cone =
packages |> OpamSolver.reverse_dependencies universe
~build:true ~post:true ~depopts:false ~installed:true
in
let keep =
universe.u_base ++ t.installed_roots %% t.installed -- remove_cone
universe.u_base ++ t.installed_roots %% t.installed -- packages
in
let keep_cone =
keep |> OpamSolver.dependencies universe
Expand All @@ -1186,11 +1182,15 @@ let remove_t ?ask ~autoremove ~force atoms t =
let autoremove =
packages ++ (t.installed -- keep_cone)
in
if atoms = [] then autoremove
else (* restrict to the dependency cone of removed pkgs *)
autoremove %%
(remove_cone |> OpamSolver.dependencies universe
~build:true ~post:true ~depopts:false ~installed:true)
if atoms = [] then autoremove else
(* restrict to the dependency cone of removed pkgs *)
let remove_cone =
packages |> OpamSolver.reverse_dependencies universe
~build:true ~post:true ~depopts:false ~installed:true
in
autoremove %%
(remove_cone |> OpamSolver.dependencies universe
~build:true ~post:true ~depopts:false ~installed:true)
else
packages
in
Expand Down
6 changes: 3 additions & 3 deletions tests/reftests/basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ The following actions would be performed:
Nothing to do.
### opam remove a --auto --show
The following actions would be performed:
- remove c 1 [uses a]
- remove a 1
===== 2 to remove =====
- remove a 1
- recompile c 1 [uses a]
===== 1 to recompile | 1 to remove =====
### :::::: message on removal of an unavailable package (#4890)
### <pkg:z.1>
opam-version: "2.0"
Expand Down

0 comments on commit 17b6cb1

Please sign in to comment.