From c7be8f4fc6e50fd81207c2feba49263cef457533 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 17 Apr 2011 09:13:49 +0200 Subject: Dump dependency cycle on error --- src/Hakyll/Core/DependencyAnalyzer.hs | 1 + src/Hakyll/Core/Run.hs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Hakyll/Core/DependencyAnalyzer.hs b/src/Hakyll/Core/DependencyAnalyzer.hs index 2f13b37..c39b399 100644 --- a/src/Hakyll/Core/DependencyAnalyzer.hs +++ b/src/Hakyll/Core/DependencyAnalyzer.hs @@ -48,6 +48,7 @@ data DependencyAnalyzer a = DependencyAnalyzer data Signal a = Build a | Cycle [a] | Done + deriving (Show) instance (Ord a, Show a) => Monoid (DependencyAnalyzer a) where mempty = DependencyAnalyzer mempty mempty mempty mempty diff --git a/src/Hakyll/Core/Run.hs b/src/Hakyll/Core/Run.hs index b076cb0..e2cab3c 100644 --- a/src/Hakyll/Core/Run.hs +++ b/src/Hakyll/Core/Run.hs @@ -6,7 +6,7 @@ module Hakyll.Core.Run ) where import Prelude hiding (reverse) -import Control.Monad (filterM) +import Control.Monad (filterM, forM_) import Control.Monad.Trans (liftIO) import Control.Applicative (Applicative, (<$>)) import Control.Monad.Reader (ReaderT, runReaderT, ask) @@ -147,9 +147,18 @@ stepAnalyzer = Runtime $ do put $ state { hakyllAnalyzer = analyzer' } case signal of Done -> return () - Cycle _ -> return () + Cycle c -> unRuntime $ dumpCycle c Build id' -> unRuntime $ build id' +-- | Dump cyclic error and quit +-- +dumpCycle :: [Identifier] -> Runtime () +dumpCycle cycle' = Runtime $ do + logger <- hakyllLogger <$> ask + section logger "Dependency cycle detected! Conflict:" + forM_ (zip cycle' $ drop 1 cycle') $ \(x, y) -> + report logger $ show x ++ " -> " ++ show y + build :: Identifier -> Runtime () build id' = Runtime $ do logger <- hakyllLogger <$> ask -- cgit v1.2.3