From efaba54abe2144f23b9cae6540f32d64f9e5adf8 Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Wed, 18 Feb 2009 23:46:50 +0000 Subject: [PATCH] Add extra assertion into the top down dep planner --- Distribution/Client/Dependency/TopDown.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Distribution/Client/Dependency/TopDown.hs b/Distribution/Client/Dependency/TopDown.hs index 33353e6ad..e7d4c99e4 100644 --- a/Distribution/Client/Dependency/TopDown.hs +++ b/Distribution/Client/Dependency/TopDown.hs @@ -64,6 +64,8 @@ import Data.Set (Set) import qualified Data.Map as Map import qualified Data.Graph as Graph import qualified Data.Array as Array +import Control.Exception + ( assert ) -- ------------------------------------------------------------ -- * Search state types @@ -445,7 +447,8 @@ finaliseSelectedPackages pref selected constraints = case PackageIndex.lookupDependency remainingChoices dep of [] -> impossible [pkg'] -> pkg' - remaining -> maximumBy bestByPref remaining + remaining -> assert (checkIsPaired remaining) + $ maximumBy bestByPref remaining -- We order candidate packages to pick for a dependency by these -- three factors. The last factor is just highest version wins. bestByPref = @@ -461,6 +464,14 @@ finaliseSelectedPackages pref selected constraints = isPreferred p = packageVersion p `withinRange` preferredVersions where (PackagePreferences preferredVersions _) = pref (packageName p) + -- We really only expect to find more than one choice remaining when + -- we're finalising a dependency on a paired package. + checkIsPaired [p1, p2] = + case Constraints.isPaired constraints (packageId p1) of + Just p2' -> packageId p2' == packageId p2 + Nothing -> False + checkIsPaired _ = False + -- | Improve an existing installation plan by, where possible, swapping -- packages we plan to install with ones that are already installed. -- This may add additional constraints due to the dependencies of installed -- 2.11.4.GIT