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

On branch  : master

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

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

commit d6504d3bb413aa141c1f93075a52367342df09c5
Author: Duncan Coutts <[email protected]>
Date:   Wed May 7 00:13:02 2008 +0000

    Reimplement InstallPlan.failed as it was completely wrong
    It was finding all the dependencies of the failed package and
    marking them as failed. But of course what we have to do is find
    all the packages that depend on the failed package (the reverse
    dependencies) and mark them as failed. We use the reverse
    dependency Graph that we saved in the InstallPlan.

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

 cabal-install/Hackage/InstallPlan.hs |   35 +++++++++++++++------------------
 1 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/cabal-install/Hackage/InstallPlan.hs 
b/cabal-install/Hackage/InstallPlan.hs
index 0f883c0..d49e4c0 100644
--- a/cabal-install/Hackage/InstallPlan.hs
+++ b/cabal-install/Hackage/InstallPlan.hs
@@ -246,26 +246,23 @@ failed :: PackageIdentifier -- ^ The id of the package 
that failed to install
        -> buildResult       -- ^ The build result to use for its dependencies
        -> InstallPlan buildResult
        -> InstallPlan buildResult
-failed pkgid buildResult dependentBuildResult
-       plan@(InstallPlan { planIndex = index }) =
-  case PackageIndex.lookupPackageId index pkgid of
-    Just (Configured cp) ->
-               plan {
-                 planIndex = markDepsAsFailed pkgid
-                           . PackageIndex.insert (Failed cp buildResult)
-                           $ index
-               }
-    Just _  -> error $ "InstallPlan.failed: not configured " ++ display pkgid
-    Nothing -> error $ "InstallPlan.failed: no such package " ++ display pkgid
+failed pkgid buildResult dependentBuildResult plan =
+  plan { planIndex = PackageIndex.merge (planIndex plan) failures }
   where
-  --markDepsAsFailed :: PackageIdentifier -> PackageIndex br -> PackageIndex br
-  markDepsAsFailed pkgid' index' =
-    case PackageIndex.lookupPackageId index' pkgid' of
-      Just (Configured cp) ->
-        let index'' = PackageIndex.insert (Failed cp dependentBuildResult) 
index'
-            deps    = depends cp
-        in foldr markDepsAsFailed index'' deps
-      _ -> index'
+    pkg = lookupConfiguredPackage plan pkgid
+    failures = PackageIndex.fromList
+             $ Failed pkg buildResult
+             : [ Failed pkg' dependentBuildResult
+               | pkgid' <- packagesThatDependOn plan pkgid
+               , let pkg' = lookupConfiguredPackage plan pkgid' ]
+
+-- | lookup the reachable packages in the reverse dependency graph
+--
+packagesThatDependOn :: InstallPlan a
+                     -> PackageIdentifier -> [PackageIdentifier]
+packagesThatDependOn plan = map (planPkgIdOf plan)
+                          . Graph.reachable (planGraphRev plan)
+                          . planVertexOf plan
 
 -- | lookup a package that we expect to be in the configured state
 --



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

Reply via email to