Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal On branch : master
http://hackage.haskell.org/trac/ghc/changeset/851beab58e0119a91d7cbbe2d7442ceed1c233cf >--------------------------------------------------------------- commit 851beab58e0119a91d7cbbe2d7442ceed1c233cf Author: Duncan Coutts <[email protected]> Date: Wed Jun 3 10:16:23 2009 +0000 Only apply preferences to base if its version is unbounded above Fixes ticket #485. This means that for constraints like: build-depends: base >= 3 && < 5 we will pick version 4. However we will continue to apply the version 3 preference for things like: build-depends: base >= 3 Where there is no upper bound on the version. Note that we now also ignore preferences for base given on the command line. We should implement #483 to split prefs from shims. >--------------------------------------------------------------- .../Distribution/Client/Dependency/TopDown.hs | 26 +++++++++++++++---- 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cabal-install/Distribution/Client/Dependency/TopDown.hs b/cabal-install/Distribution/Client/Dependency/TopDown.hs index e30182a..746c4d4 100644 --- a/cabal-install/Distribution/Client/Dependency/TopDown.hs +++ b/cabal-install/Distribution/Client/Dependency/TopDown.hs @@ -41,7 +41,8 @@ import Distribution.PackageDescription import Distribution.PackageDescription.Configuration ( finalizePackageDescription, flattenPackageDescription ) import Distribution.Version - ( VersionRange, anyVersion, withinRange, simplifyVersionRange ) + ( VersionRange, anyVersion, withinRange, simplifyVersionRange + , UpperBound(..), asVersionIntervals ) import Distribution.Compiler ( CompilerId ) import Distribution.System @@ -442,13 +443,15 @@ finaliseSelectedPackages pref selected constraints = finaliseAvailable mipkg (SemiConfiguredPackage pkg flags deps) = InstallPlan.Configured (ConfiguredPackage pkg flags deps') where - deps' = map (packageId . pickRemaining) deps - pickRemaining dep = + deps' = map (packageId . pickRemaining mipkg) deps + + pickRemaining mipkg dep@(Dependency _name versionRange) = case PackageIndex.lookupDependency remainingChoices dep of [] -> impossible [pkg'] -> pkg' remaining -> assert (checkIsPaired remaining) $ maximumBy bestByPref remaining + where -- We order candidate packages to pick for a dependency by these -- three factors. The last factor is just highest version wins. bestByPref = @@ -459,11 +462,22 @@ finaliseSelectedPackages pref selected constraints = isCurrent = case mipkg :: Maybe InstalledPackage of Nothing -> \_ -> False Just ipkg -> \p -> packageId p `elem` depends ipkg - -- Is this package a preferred version acording to the hackage or - -- user's suggested version constraints - isPreferred p = packageVersion p `withinRange` preferredVersions + -- If there is no upper bound on the version range then we apply a + -- preferred version acording to the hackage or user's suggested + -- version constraints. TODO: distinguish hacks from prefs + bounded = boundedAbove versionRange + isPreferred p + | bounded = True -- any constant will do + | otherwise = packageVersion p `withinRange` preferredVersions where (PackagePreferences preferredVersions _) = pref (packageName p) + boundedAbove :: VersionRange -> Bool + boundedAbove vr = case asVersionIntervals vr of + [] -> True -- this is the inconsistent version range. + intervals -> case last intervals of + (_, UpperBound _ _) -> True + (_, NoUpperBound ) -> False + -- We really only expect to find more than one choice remaining when -- we're finalising a dependency on a paired package. checkIsPaired [p1, p2] = _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
