[commit: Cabal] master: Add extra assertion into the top down dep planner (142a0fe)
Ian Lynagh
igloo at earth.li
Fri Jun 24 02:03:03 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/142a0fef937dbd2c2c33725d065cb0ab5141d5d4
>---------------------------------------------------------------
commit 142a0fef937dbd2c2c33725d065cb0ab5141d5d4
Author: Duncan Coutts <duncan at haskell.org>
Date: Wed Feb 18 23:46:50 2009 +0000
Add extra assertion into the top down dep planner
>---------------------------------------------------------------
.../Distribution/Client/Dependency/TopDown.hs | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/cabal-install/Distribution/Client/Dependency/TopDown.hs b/cabal-install/Distribution/Client/Dependency/TopDown.hs
index 33353e6..e7d4c99 100644
--- a/cabal-install/Distribution/Client/Dependency/TopDown.hs
+++ b/cabal-install/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
More information about the Cvs-libraries
mailing list