diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-14 15:49:19 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-14 15:50:38 -0400 |
commit | 182f4fb8dc8d8b104ed537af324d76cc0079e882 (patch) | |
tree | 5b29d39b3ab4d69cb68ecb3e155dacee6bf471da /Build | |
parent | 9c17328574b2613ccac156ba1f2d1f748f222c8a (diff) |
avoid updating a file if the old splice is the same as the new
Diffstat (limited to 'Build')
-rw-r--r-- | Build/EvilSplicer.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Build/EvilSplicer.hs b/Build/EvilSplicer.hs index 3927fcc5a..2a1984ed6 100644 --- a/Build/EvilSplicer.hs +++ b/Build/EvilSplicer.hs @@ -35,6 +35,7 @@ import Data.Char import System.Environment import System.FilePath import System.Directory +import Control.Monad import Utility.Monad import Utility.Misc @@ -179,7 +180,10 @@ applySplices destdir imports l@(first:_) = do putStrLn $ "splicing " ++ f lls <- map (++ "\n") . lines <$> readFileStrict f createDirectoryIfMissing True (parentDir dest) - writeFile dest $ concat $ addimports $ expand lls l + let newcontent = concat $ addimports $ expand lls l + oldcontent <- catchMaybeIO $ readFile dest + when (oldcontent /= Just newcontent) $ + writeFile dest newcontent where expand lls [] = lls expand lls (s:rest) = expand (expandSplice s lls) rest |