Skip to content

Commit

Permalink
Fix opam tree --tree --doc assigning the with-{test,doc} variables to…
Browse files Browse the repository at this point in the history
… unrequested packages
  • Loading branch information
kit-ty-kate committed Apr 10, 2024
1 parent dbbd2a1 commit ab70c2a
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/client/opamTreeCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,35 @@ let print_solution st new_st missing solution =

(** Setting states for building *)

let get_universe tog st =
let get_universe tog requested st =
let OpamListCommand.{doc; test; dev_setup; dev; _} = tog in
OpamSwitchState.universe st ~doc ~test ~dev_setup ~force_dev_deps:dev
~requested:st.installed
~requested
Query

let simulate_new_state tog st universe install names =
let get_installed st atoms =
let open OpamPackage.Set.Op in
List.fold_left (fun (select, missing) atom ->
let installed =
OpamPackage.Set.filter (OpamFormula.check atom) st.installed
in
if OpamPackage.Set.is_empty installed then
(select, atom :: missing)
else (installed ++ select, missing))
(OpamPackage.Set.empty, []) atoms

let dry_install tog st universe install =
match OpamSolver.resolve universe
(OpamSolver.request ~install ()) with
| Success solution ->
let new_st = OpamSolution.dry_run st solution in
print_solution st new_st names solution;
new_st, get_universe tog new_st
print_solution st new_st
(OpamPackage.Name.Set.of_list (List.map fst install))
solution;
let select, missing = get_installed new_st install in
if missing <> [] then
assert false;
new_st, get_universe tog select new_st
| Conflicts cs ->
OpamConsole.error
"Could not simulate installing the specified package(s) to this switch:";
Expand All @@ -399,24 +415,11 @@ let simulate_new_state tog st universe install names =
(OpamSwitchState.unavailable_reason st) cs);
OpamStd.Sys.exit_because `No_solution

let dry_install tog st universe install =
simulate_new_state tog st universe install
(OpamPackage.Name.Set.of_list (List.map fst install))

let run st tog ?no_constraint mode filter atoms =
let open OpamPackage.Set.Op in
let select, missing =
List.fold_left (fun (select, missing) atom ->
let installed =
OpamPackage.Set.filter (OpamFormula.check atom) st.installed
in
if OpamPackage.Set.is_empty installed then
(select, atom :: missing)
else (installed ++ select, missing))
(OpamPackage.Set.empty, []) atoms
in
let select, missing = get_installed st atoms in
let st, universe =
let universe = get_universe tog st in
let universe = get_universe tog select st in
match mode, filter, missing with
| Deps, _, [] -> st, universe
| Deps, Roots_from, _::_ ->
Expand Down

0 comments on commit ab70c2a

Please sign in to comment.