[commit: packages/Cabal] ghc-head: Show the error message only if the error actually occurred. (e2b4aa4)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:28:55 CEST 2013


Repository : ssh://git@git.haskell.org/Cabal

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=e2b4aa49be9e35a4782fb8fc2ce54bd8e3c4fdab

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

commit e2b4aa49be9e35a4782fb8fc2ce54bd8e3c4fdab
Author: Mikhail Glushenkov <mikhail.glushenkov at gmail.com>
Date:   Wed Jul 24 10:52:28 2013 +0200

    Show the error message only if the error actually occurred.


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

e2b4aa49be9e35a4782fb8fc2ce54bd8e3c4fdab
 .../Distribution/Client/Sandbox/Timestamp.hs       |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/cabal-install/Distribution/Client/Sandbox/Timestamp.hs b/cabal-install/Distribution/Client/Sandbox/Timestamp.hs
index fa2495b..c53eea5 100644
--- a/cabal-install/Distribution/Client/Sandbox/Timestamp.hs
+++ b/cabal-install/Distribution/Client/Sandbox/Timestamp.hs
@@ -17,7 +17,7 @@ module Distribution.Client.Sandbox.Timestamp (
   listModifiedDeps,
   ) where
 
-import Control.Exception                             (finally)
+import Control.Exception                             (finally, onException)
 import Control.Monad                                 (filterM, forM, when)
 import Data.Char                                     (isSpace)
 import Data.List                                     (partition)
@@ -229,17 +229,21 @@ allPackageSourceFiles verbosity packageDir = inDir (Just packageDir) $ do
         useCabalVersion = orLaterVersion $ Version [1,17,0] []
         }
 
-      onFailedListSources :: IO ()
-      onFailedListSources = do
+      doListSources :: IO [FilePath]
+      doListSources = do
+        setupWrapper verbosity setupOpts (Just pkg) sdistCommand (const flags) []
+        srcs <- fmap lines . readFile $ file
+        mapM tryCanonicalizePath srcs
+
+      cleanupAfterListSources, onFailedListSources :: IO ()
+      cleanupAfterListSources = removeExistingFile file
+      onFailedListSources     =
         warn verbosity $ "Couldn't list sources of the package '"
           ++ display (packageName pkg) ++ "'"
-        removeExistingFile file
 
   -- Run setup sdist --list-sources=TMPFILE
-  (flip finally) (onFailedListSources) $ do
-    setupWrapper verbosity setupOpts (Just pkg) sdistCommand (const flags) []
-    srcs <- fmap lines . readFile $ file
-    mapM tryCanonicalizePath srcs
+  (doListSources `finally` cleanupAfterListSources)
+    `onException` onFailedListSources
 
 -- | Has this dependency been modified since we have last looked at it?
 isDepModified :: Verbosity -> EpochTime -> AddSourceTimestamp -> IO Bool





More information about the ghc-commits mailing list