]> _ Git - alire.git/commit
Internal enhancements to Solution and Dependency states (#429)
authorAlejandro R Mosteo <alejandro@mosteo.com>
Thu, 11 Jun 2020 11:33:39 +0000 (13:33 +0200)
committerGitHub <noreply@github.com>
Thu, 11 Jun 2020 11:33:39 +0000 (13:33 +0200)
commit738e4b43cf696f5c387ed3b313390ad189d99428
treedbfc2f179177652ac8bde2773fe5199484537afb
parent55d993ec7af397399a56a3d7c8b6c6efa3fd4732
Internal enhancements to Solution and Dependency states (#429)

* Remove obsolete Alire.Dependencies.Unavailable

This fake dependency was used in the old Ada index to store an unavailable
dependency. There is no longer any use for this constant.

* Image functions for newly tagged Alire.Milestones

Make the type tagged to gain dot notation, and add [TTY_]Image subprograms for
simpler printing elsewhere.

* New Alire.Dependencies.States type

This type is used to store the actual way in which a dependency was solved. All
possibilities are stored, which allows to properly cache a solution, and detect
changes in solutions across operations that modify the solution: pinning,
withing, updating...

* New Alire.Dependencies.States.Maps

A crate name -> dep state mapping which is at the core of the cached Solution,
with a couple of functional-style modifiers for use in expression functions.

* Remove pinning info from Releases

This information is now stored in the dependency State where it better belongs.
This way it doesn't matter if the solution contains a release for the pinned
dependency; the pinning information is always preserved.

* Reworked Solution internals to use States

(Doesn't build.) Changes to Alire.Solutions to use the new dependency states.
With these changes there is no loss of information when going from a valid to
an invalid solution (information about partial solutions is stored the same as
for complete solutions), which enables down the road better feedback to users
and simpler implementation of other improvements, like pinning of crates to
local folders.

* Solver improvements based on new dependency states

(Only alire-solver.adb builds.) With these changes, the solver needs not to
check the complete validity of a solution once all dependencies are processed
(which is an expensive test), because validity is guaranteed for any partial
solution (that is, no incompatible release can make into the solution). Also,
while the solver was previously complete in regard to valid solutions (with
releases or hints), now it is also complete for invalid solutions (those
missing releases and hints for some dependency). This means that the solver
will return the "best" incomplete solution when a complete one cannot be found.

* Tweaks to achieve build with new Solution

A few minor changes due to changes in the Solution public methods are needed
here and there, without functional implications.

* Tweaks for testsuite compliance

A few changes are needed to ensure the same output as before is produced, or to
adapt a few tests to minimal output changes caused by the homogenization of
dependency images.

* Make Alire.Crate_Name a proper private type

Our Dynamic_Predicate in the publicly defined Crate_Name as new String is
rejected by GNAT 9, and I couldn't find a workaround short of making all of
Alire.* non-preelaborable. Defining privately Crate_Name as new String in turn
caused numerous errors in child packages due to some mixing between the public
and private views. In the end, making it a record was the simplest change
without introducing the risk of missing checks (as if we had made it simply a
subtype of String).

So, given the change, I bit the bullet to make it tagged and provide a couple
of convenience functions.

* Review fixes
45 files changed:
deps/semantic_versioning
deps/simple_logging
src/alire/alire-conditional-operations.ads [deleted file]
src/alire/alire-containers.adb
src/alire/alire-containers.ads
src/alire/alire-crates-with_releases.adb
src/alire/alire-crates-with_releases.ads
src/alire/alire-dependencies-graphs.adb
src/alire/alire-dependencies-graphs.ads
src/alire/alire-dependencies-states-maps.adb [new file with mode: 0644]
src/alire/alire-dependencies-states-maps.ads [new file with mode: 0644]
src/alire/alire-dependencies-states.adb [new file with mode: 0644]
src/alire/alire-dependencies-states.ads [new file with mode: 0644]
src/alire/alire-dependencies.ads
src/alire/alire-externals-unindexed.adb
src/alire/alire-index_on_disk.adb
src/alire/alire-lockfiles.adb
src/alire/alire-milestones.ads
src/alire/alire-pinning.adb
src/alire/alire-pinning.ads
src/alire/alire-releases.adb
src/alire/alire-releases.ads
src/alire/alire-solutions-diffs.adb
src/alire/alire-solutions-diffs.ads
src/alire/alire-solutions.adb
src/alire/alire-solutions.ads
src/alire/alire-solver.adb
src/alire/alire-solver.ads
src/alire/alire.adb
src/alire/alire.ads
src/alr/alr-build_env.adb
src/alr/alr-checkout.adb
src/alr/alr-commands-get.adb
src/alr/alr-commands-pin.adb
src/alr/alr-commands-search.adb
src/alr/alr-commands-show.adb
src/alr/alr-commands-update.adb
src/alr/alr-commands.adb
testsuite/tests/get/only/test.py
testsuite/tests/get/system-hint/test.py
testsuite/tests/index/external-available/test.py
testsuite/tests/index/external-from-output/test.py
testsuite/tests/pin/downgrade/test.py
testsuite/tests/pin/post-update/test.py
testsuite/tests/run/defaults/my_index/index/index.toml [deleted file]