Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/df947224f76c7fb41e3bda9e36361698ff1d6b39

>---------------------------------------------------------------

commit df947224f76c7fb41e3bda9e36361698ff1d6b39
Author: Duncan Coutts <[email protected]>
Date:   Mon Jun 2 16:39:44 2008 +0000

    Fix improvePlan so the index is updated incrementally
    It's important since later packages can depend on earlier ones having
    been changed from configured to pre-existing. That is afterall the
    whole point of considering them in reverse toplogical order.
    Also, remove duplicates in the dependencies list of installed
    packages since ghc-pkg does not currently prevent duplicates in (eg
    multiple depends on the same version of base). See ghc bug #2230.

>---------------------------------------------------------------

 cabal-install/Hackage/Dependency/TopDown.hs |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/cabal-install/Hackage/Dependency/TopDown.hs 
b/cabal-install/Hackage/Dependency/TopDown.hs
index 051d284..215d9b0 100644
--- a/cabal-install/Hackage/Dependency/TopDown.hs
+++ b/cabal-install/Hackage/Dependency/TopDown.hs
@@ -345,23 +345,24 @@ improvePlan installed selected = foldl' improve selected
                                $ reverseTopologicalOrder selected
   where
     improve selected' = maybe selected' (flip PackageIndex.insert selected')
-                      . improvePkg
+                      . improvePkg selected'
 
     -- The idea is to improve the plan by swapping a configured package for
     -- an equivalent installed one. For a particular package the condition is
     -- that the package be in a configured state, that a the same version be
     -- already installed with the exact same dependencies and all the packages
     -- in the plan that it depends on are in the installed state
-    improvePkg pkgid = do
-      Configured pkg  <- PackageIndex.lookupPackageId selected  pkgid
+    improvePkg selected' pkgid = do
+      Configured pkg  <- PackageIndex.lookupPackageId selected' pkgid
       ipkg            <- PackageIndex.lookupPackageId installed pkgid
-      guard $ sort (depends pkg) == sort (depends ipkg)
-      guard $ all isInstalled (depends pkg)
+      guard $ sort (depends pkg) == nub (sort (depends ipkg))
+      guard $ all (isInstalled selected') (depends pkg)
       return (PreExisting ipkg)
 
-    isInstalled pkgid = case PackageIndex.lookupPackageId selected pkgid of
-      Just (PreExisting _) -> True
-      _                    -> False
+    isInstalled selected' pkgid =
+      case PackageIndex.lookupPackageId selected' pkgid of
+        Just (PreExisting _) -> True
+        _                    -> False
 
     reverseTopologicalOrder :: PackageFixedDeps pkg => PackageIndex pkg
                             -> [PackageIdentifier]



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to