Commit 991e52a4 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Relax dependencyInconsistencies to allow the base-3,4 thing

Previously we said a package graph was inconsistent if two
dependencies on the same package name specified different
versions. Now we say that two such dependencies on different
versions are ok if there is a direct dependency between those
two package versions. So if your package graph ends up with
both base 3 and base 4 in it, then that's ok because base 3
directly depends on base 4, so we declare it not to be an
inconsistency. This removes the scary warnings at configure
time (fixing ticket #366) and also adjusts the invariant and
assertion of the InstallPlan ADT in cabal-install.
parent a9c73c88
......@@ -66,15 +66,15 @@ import qualified Data.Graph as Graph
import qualified Data.Array as Array
import Data.Array ((!))
#if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ < 606)
import Data.List (groupBy, sortBy, find, isPrefixOf, tails)
import Data.List (groupBy, sortBy, nub, find, isPrefixOf, tails)
#else
import Data.List (groupBy, sortBy, find, isInfixOf)
import Data.List (groupBy, sortBy, nub, find, isInfixOf)
#endif
import Data.Monoid (Monoid(..))
import Data.Maybe (isNothing, fromMaybe)
import Distribution.Package
( PackageName(..), PackageIdentifier
( PackageName(..), PackageIdentifier(..)
, Package(..), packageName, packageVersion
, Dependency(Dependency), PackageFixedDeps(..) )
import Distribution.Version
......@@ -447,7 +447,8 @@ dependencyInconsistencies index =
[ (name, inconsistencies)
| (name, uses) <- Map.toList inverseIndex
, let inconsistencies = duplicatesBy uses
, not (null inconsistencies) ]
versions = map snd inconsistencies
, reallyIsInconsistent name (nub versions) ]
where inverseIndex = Map.fromListWith (++)
[ (packageName dep, [(packageId pkg, packageVersion dep)])
......@@ -460,6 +461,21 @@ dependencyInconsistencies index =
. groupBy (equating snd)
. sortBy (comparing snd)
reallyIsInconsistent :: PackageName -> [Version] -> Bool
reallyIsInconsistent _ [] = False
reallyIsInconsistent name [v1, v2] =
case (mpkg1, mpkg2) of
(Just pkg1, Just pkg2) -> pkgid1 `notElem` depends pkg2
&& pkgid2 `notElem` depends pkg1
_ -> True
where
pkgid1 = PackageIdentifier name v1
pkgid2 = PackageIdentifier name v2
mpkg1 = lookupPackageId index pkgid1
mpkg2 = lookupPackageId index pkgid2
reallyIsInconsistent _ _ = True
-- | Find if there are any cycles in the dependency graph. If there are no
-- cycles the result is @[]@.
--
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment