From b692cc2e71a03adfe3cf79c66633a775aad1651d Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Sun, 20 May 2018 14:40:25 +0200 Subject: [PATCH] Closing alr #39 --- src/alire-index.ads | 13 +++++++++---- src/alire-releases.adb | 12 ++++++++++++ src/alire-releases.ads | 3 +++ src/alire-utils.adb | 16 ++++++++++++++++ src/alire-utils.ads | 10 +++++++++- 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/alire-index.ads b/src/alire-index.ads index 3b0df2c6..7a585e33 100644 --- a/src/alire-index.ads +++ b/src/alire-index.ads @@ -345,6 +345,13 @@ package Alire.Index is ------------ -- The root determines the starting point to look for dependencies + function New_Working_Release + (Project : Alire.Project; + Origin : Origins.Origin := Origins.New_Filesystem ("."); + Dependencies : Conditional.Dependencies := Conditional.For_Dependencies.Empty; + Properties : Conditional.Properties := Conditional.For_Properties.Empty) + return Release renames Releases.New_Working_Release; + subtype Root is Roots.Root; function Set_Root (Project : Catalog_Entry; @@ -352,10 +359,8 @@ package Alire.Index is return Roots.Root is (Alire.Root.Set (Project.Project, Version)); -- All information will be taken from the indexed release - function Set_Root (Project : Alire.Project; - Dependencies : Conditional.Dependencies) - return Roots.Root renames Alire.Root.Set; - -- An unindexed working copy + function Set_Root (R : Release) return Roots.Root renames Alire.Root.Set; + -- An unindexed working copy (See New_Working_Release) private diff --git a/src/alire-releases.adb b/src/alire-releases.adb index e4ef3ada..34315cef 100644 --- a/src/alire-releases.adb +++ b/src/alire-releases.adb @@ -77,6 +77,18 @@ package body Alire.Releases is -- Replacing -- --------------- + function Replacing (Base : Release; + Dependencies : Conditional.Dependencies) return Release is + begin + return Replaced : Release := Base do + Replaced.Dependencies := Dependencies; + end return; + end Replacing; + + --------------- + -- Replacing -- + --------------- + function Replacing (Base : Release; Project : Alire.Project := ""; Notes : Description_String := "") return Release diff --git a/src/alire-releases.ads b/src/alire-releases.ads index 2507d678..f20a0e2e 100644 --- a/src/alire-releases.ads +++ b/src/alire-releases.ads @@ -66,6 +66,9 @@ package Alire.Releases with Preelaborate is Notes : Description_String := "") return Release; -- Takes a release and replaces the given fields + function Replacing (Base : Release; + Dependencies : Conditional.Dependencies) return Release; + function Replacing (Base : Release; Origin : Origins.Origin) return Release; diff --git a/src/alire-utils.adb b/src/alire-utils.adb index 27f4daf4..9889a361 100644 --- a/src/alire-utils.adb +++ b/src/alire-utils.adb @@ -7,6 +7,22 @@ with GNAT.OS_Lib; package body Alire.Utils is + ------------------------- + -- Append_To_Last_Line -- + ------------------------- + + function Append_To_Last_Line (V : String_Vector; S : String) return String_Vector is + begin + if V.Is_Empty then + return To_Vector (S); + else + return R : String_Vector := V do + R.Delete_Last; + R.Append_Line (V.Last_Element & S); + end return; + end if; + end Append_To_Last_Line; + -------------- -- Contains -- -------------- diff --git a/src/alire-utils.ads b/src/alire-utils.ads index 06bba4cd..af7df9ce 100644 --- a/src/alire-utils.ads +++ b/src/alire-utils.ads @@ -1,3 +1,4 @@ +with Ada.Containers; with Ada.Containers.Indefinite_Ordered_Sets; with Ada.Containers.Indefinite_Vectors; @@ -56,8 +57,15 @@ package Alire.Utils with Preelaborate is Empty_Vector : constant String_Vector; + procedure Append_Line (V : in out String_Vector; + S : String; + C : Ada.Containers.Count_Type := 1) + renames Append; + procedure Append_Vector (V : in out String_Vector; V2 : String_Vector) - renames Append; + renames Append; + + function Append_To_Last_Line (V : String_Vector; S : String) return String_Vector; function Count (V : String_Vector) return Natural; -- FSM do I hate the Containers.Count_Type...