From 85b8723847ffe131068701e01ad9d7e721446abd Mon Sep 17 00:00:00 2001 From: "Alejandro R. Mosteo" Date: Mon, 6 Jan 2025 11:57:15 +0100 Subject: [PATCH] Even more concise No point in having an extra line for one single elided dependency, which happens often. --- src/alire/alire-solutions.adb | 86 ++++++++++++----------- testsuite/tests/with/tree-concise/test.py | 3 +- 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/src/alire/alire-solutions.adb b/src/alire/alire-solutions.adb index b692a7583..9b8809146 100644 --- a/src/alire/alire-solutions.adb +++ b/src/alire/alire-solutions.adb @@ -926,6 +926,8 @@ package body Alire.Solutions is (if TTY.Color_Enabled then U ("└── ") else "+-- "); Branch : constant String := (if TTY.Color_Enabled then U ("│ ") else "| "); + More_Deps : constant String := + (if TTY.Color_Enabled then U (" ···") else " ..."); No_Branch : constant String := " "; Printed : AAA.Strings.Sets.Set; @@ -950,6 +952,26 @@ package body Alire.Solutions is -- Omit is used to remove the top-level connectors, for when the tree -- is printed without the root release. is + + ------------------------------------- + -- Inline_Concise_Marker_If_Needed -- + ------------------------------------- + + function Inline_Concise_Marker_If_Needed + (Dep : Dependencies.Dependency) return String is + begin + if Concise + and then Printed.Contains (Label (Dep)) + and then This.State (Dep.Crate).Has_Release + and then not Conditional.Enumerate + (This.State (Dep.Crate).Release.Dependencies).Is_Empty + then + return More_Deps; + else + return ""; + end if; + end Inline_Concise_Marker_If_Needed; + Last : UString; -- Used to store the last dependency name in a subtree, to be able to -- use the proper ASCII connector. See just below. @@ -986,46 +1008,30 @@ package body Alire.Solutions is & Label (Dep) -- And dependency that introduces the crate in the solution - & " (" & TTY.Emph (Dep.Versions.Image) & ")"); - - -- Recurse for further releases - - if This.State (Dep.Crate).Has_Release then - if Concise - and then Printed.Contains (Label (Dep)) - and then not - Conditional.Enumerate - (This.State (Dep.Crate).Release.Dependencies).Is_Empty - then - Trace.Always - (Prefix - -- The prefix is the possible "|" connectors from - -- upper tree levels. - & (if Omit - then "" - else (if +Dep.Crate = +Last - then No_Branch -- End of this connector - else Branch)) -- "│" over the subtree - - -- Print the appropriate final connector for the node - & (if Omit -- top-level, no prefix - then "" - else Last_Node) - - & "..."); - else - Print - (Conditional.Enumerate - (This.State (Dep.Crate).Release.Dependencies).To_Set, - Prefix => - Prefix - -- Indent adding the proper running connector - & (if Omit - then "" - else (if +Dep.Crate = +Last - then No_Branch -- End of this connector - else Branch))); -- "│" over the subtree - end if; + & " (" & TTY.Emph (Dep.Versions.Image) & ")" + + -- If concise and this has dependencies, print the marker + & Inline_Concise_Marker_If_Needed (Dep) + ); + + -- Recurse for further releases if not conise and printed + + if (not Concise or else not Printed.Contains (Label (Dep))) + and then This.State (Dep.Crate).Has_Release + and then not Conditional.Enumerate + (This.State (Dep.Crate).Release.Dependencies).Is_Empty + then + Print + (Conditional.Enumerate + (This.State (Dep.Crate).Release.Dependencies).To_Set, + Prefix => + Prefix + -- Indent adding the proper running connector + & (if Omit + then "" + else (if +Dep.Crate = +Last + then No_Branch -- End of this connector + else Branch))); -- "│" over the subtree end if; Printed.Include (Label (Dep)); diff --git a/testsuite/tests/with/tree-concise/test.py b/testsuite/tests/with/tree-concise/test.py index c08a3fb6e..290638d5d 100644 --- a/testsuite/tests/with/tree-concise/test.py +++ b/testsuite/tests/with/tree-concise/test.py @@ -24,8 +24,7 @@ +-- hello=1.0.1 (*) | +-- libhello=1.0.0 (^1.0) +-- yyy=0.1.0-dev (*) - +-- hello=1.0.1 (*) - +-- ...\ + +-- hello=1.0.1 (*) ...\ """, run_alr("with", "--tree").out.strip())