From 2550fdde4d59442339fcacba1f7fb3cd4bb7a259 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Fri, 12 Jun 2020 15:24:26 +0200 Subject: [PATCH] Remove some unnecessary code after Solution changes (#431) The solution stores platform-dependent releases, hence the Environment parameter is not needed at the moment of writing the corresponding lockfile. A stray exception handler in Alr.Commands.Withing was unneeded and masking as a regular error some Constraint_Errors that should escalate to the main handler to be reported as unexpected internal errors. Dead code in Alire.Utils that is not going to be useful again has been removed. --- src/alire/alire-lockfiles.adb | 6 ++---- src/alire/alire-lockfiles.ads | 1 - src/alire/alire-utils.ads | 10 ---------- src/alr/alr-checkout.adb | 4 +--- src/alr/alr-commands-init.adb | 2 -- src/alr/alr-commands-pin.adb | 5 ++--- src/alr/alr-commands-withing.adb | 6 ------ src/alr/alr-commands.adb | 5 +---- 8 files changed, 6 insertions(+), 33 deletions(-) diff --git a/src/alire/alire-lockfiles.adb b/src/alire/alire-lockfiles.adb index 966b3a87..1111a067 100644 --- a/src/alire/alire-lockfiles.adb +++ b/src/alire/alire-lockfiles.adb @@ -70,11 +70,9 @@ package body Alire.Lockfiles is -- Write -- ----------- - procedure Write (Solution : Solver.Solution; - Environment : Properties.Vector; - Filename : Any_Path) + procedure Write (Solution : Solver.Solution; + Filename : Any_Path) is - pragma Unreferenced (Environment); use Ada.Text_IO; File : File_Type; begin diff --git a/src/alire/alire-lockfiles.ads b/src/alire/alire-lockfiles.ads index c6677dfa..e8177b9f 100644 --- a/src/alire/alire-lockfiles.ads +++ b/src/alire/alire-lockfiles.ads @@ -22,7 +22,6 @@ package Alire.Lockfiles is -- Check if given file is a valid lockfile procedure Write (Solution : Solver.Solution; - Environment : Properties.Vector; Filename : Any_Path); -- Write a solution to a file diff --git a/src/alire/alire-utils.ads b/src/alire/alire-utils.ads index 77ecfc66..aaa4facf 100644 --- a/src/alire/alire-utils.ads +++ b/src/alire/alire-utils.ads @@ -185,13 +185,6 @@ package Alire.Utils with Preelaborate is Separator : String := ASCII.LF & ""); -- Dump contents to a given file - ----------------- - -- XXX_XXX_XXX -- - ----------------- - - type XXX_XXX (<>) is limited private; - function XXX_XXX_XXX return XXX_XXX; - private Empty_Vector : constant String_Vector := @@ -206,7 +199,4 @@ private function Trim (S : String) return String is (Ada.Strings.Fixed.Trim (S, Ada.Strings.Both)); - type XXX_XXX is limited null record; - function XXX_XXX_XXX return XXX_XXX is (null record); - end Alire.Utils; diff --git a/src/alr/alr-checkout.adb b/src/alr/alr-checkout.adb index 42e9697b..fe9a5e39 100644 --- a/src/alr/alr-checkout.adb +++ b/src/alr/alr-checkout.adb @@ -103,7 +103,6 @@ package body Alr.Checkout is Alire.Lockfiles.Write (Solution, - Platform.Properties, Alire.Lockfiles.File_Name (Name => Root, Root_Dir => Root_Dir)); @@ -185,14 +184,13 @@ package body Alr.Checkout is Templates.Generate_Prj_Alr (R.Whenever (Platform.Properties), Root.Crate_File); - -- Create also an invalid solution lockfile (since dependencies + -- Create also an incomplete solution lockfile (since dependencies -- are still unretrieved). Once they are checked out, the lockfile -- will be replaced with the complete solution. Alire.Lockfiles.Write (Solution => (if R.Dependencies (Platform.Properties).Is_Empty then Alire.Solutions.Empty_Valid_Solution else Alire.Solutions.Empty_Invalid_Solution), - Environment => Platform.Properties, Filename => Root.Lock_File); end; end if; diff --git a/src/alr/alr-commands-init.adb b/src/alr/alr-commands-init.adb index c9bfa987..0cd97c8f 100644 --- a/src/alr/alr-commands-init.adb +++ b/src/alr/alr-commands-init.adb @@ -8,7 +8,6 @@ with Alire.Releases; with Alire.Roots; with Alire.Solutions; -with Alr.Platform; with Alr.Root; with Alr.Templates; with Alr.Utils; @@ -177,7 +176,6 @@ package body Alr.Commands.Init is Alire.Lockfiles.Write (Alire.Solutions.Empty_Valid_Solution, - Platform.Properties, Root.Lock_File); end; end Generate; diff --git a/src/alr/alr-commands-pin.adb b/src/alr/alr-commands-pin.adb index 77f49622..685226b0 100644 --- a/src/alr/alr-commands-pin.adb +++ b/src/alr/alr-commands-pin.adb @@ -140,9 +140,8 @@ package body Alr.Commands.Pin is if Commands.User_Input.Confirm_Solution_Changes (Diff, Changed_Only => not Alire.Detailed) then - Alire.Lockfiles.Write (Solution => New_Sol, - Environment => Platform.Properties, - Filename => Root.Current.Lock_File); + Alire.Lockfiles.Write (Solution => New_Sol, + Filename => Root.Current.Lock_File); -- We force the update because we have just stored the new -- solution, so Update won't detect any changes. diff --git a/src/alr/alr-commands-withing.adb b/src/alr/alr-commands-withing.adb index 803d791f..83327891 100644 --- a/src/alr/alr-commands-withing.adb +++ b/src/alr/alr-commands-withing.adb @@ -15,7 +15,6 @@ with Alire.Utils; with Alr.Commands.Update; with Alr.Commands.User_Input; -with Alr.Exceptions; with Alr.OS_Lib; with Alr.Platform; with Alr.Root; @@ -378,11 +377,6 @@ package body Alr.Commands.Withing is else raise Program_Error with "List should have already happened"; end if; - exception - when E : Constraint_Error => - Exceptions.Report ("In Withing.Execute:", E); - Reportaise_Command_Failed - ("Could not locate package containing releases of " & Argument (1)); end Execute; ---------------------- diff --git a/src/alr/alr-commands.adb b/src/alr/alr-commands.adb index a7204b24..cb188b4f 100644 --- a/src/alr/alr-commands.adb +++ b/src/alr/alr-commands.adb @@ -485,10 +485,7 @@ package body Alr.Commands is Platform.Properties, Alire.Solutions.Empty_Valid_Solution); begin - Alire.Lockfiles.Write - (Solution, - Platform.Properties, - Checked.Lock_File); + Alire.Lockfiles.Write (Solution, Checked.Lock_File); end; end Requires_Valid_Session; -- 2.39.5