From fafdf10eb50214ee580a2ca4fd1a85b5009acebf Mon Sep 17 00:00:00 2001 From: cannorin Date: Wed, 10 Aug 2022 19:33:23 +0200 Subject: [PATCH] solution: add dry_run function to simulate a state from a solution --- src/client/opamSolution.ml | 3 +++ src/client/opamSolution.mli | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/client/opamSolution.ml b/src/client/opamSolution.ml index 0d88677086d..70cc31da7bc 100644 --- a/src/client/opamSolution.ml +++ b/src/client/opamSolution.ml @@ -1039,6 +1039,9 @@ let simulate_new_state state t = t state.installed in { state with installed } +let dry_run state solution = + simulate_new_state state (OpamSolver.get_atomic_action_graph solution) + (* Ask confirmation whenever the packages to modify are not exactly the packages in the user request *) let confirmation ?ask requested solution = diff --git a/src/client/opamSolution.mli b/src/client/opamSolution.mli index d8e45b3c0de..7e3a6ece557 100644 --- a/src/client/opamSolution.mli +++ b/src/client/opamSolution.mli @@ -71,6 +71,10 @@ val check_solution: (solution_result, 'conflict) result -> unit +(** Simulate the new [switch_state] after applying the [solution] + without actually performing the action(s) on disk. *) +val dry_run: 'a switch_state -> OpamSolver.solution -> 'a switch_state + (* Install external dependencies of the given package set, according the depext configuration. If [confirm] is false, install commands are directly launched, without asking user (used by the `--depext-only` option). If