filediff 1.0.0.0 → 1.0.0.1
raw patch · 2 files changed
+15/−3 lines, 2 filesdep +threadsPVP ok
version bump matches the API change (PVP)
Dependencies added: threads
API changes (from Hackage documentation)
Files
- filediff.cabal +2/−2
- src/Filediff.hs +13/−1
filediff.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: filediff-version: 1.0.0.0+version: 1.0.0.1 synopsis: Diffing and patching module description: `filediff` is a Haskell library for creating diffs, and applying diffs to files and directories. homepage: https://github.com/bgwines/filediff@@ -23,7 +23,7 @@ exposed-modules: Filediff, Filediff.Types, Filediff.Stats, Filediff.Printing other-modules: Filediff.Utils -- other-extensions:- build-depends: base >=4.7 && <4.8, mtl, time, directory, either, transformers, data-memocombinators, Zora >=1.1.22, text, data-default, tasty, tasty-hunit, rainbow, bytestring+ build-depends: base >=4.7 && <4.8, mtl, time, directory, either, transformers, data-memocombinators, Zora >=1.1.22, text, data-default, tasty, tasty-hunit, rainbow, bytestring, threads hs-source-dirs: src default-language: Haskell2010
src/Filediff.hs view
@@ -17,6 +17,10 @@ , applyToDirectory ) where +import Control.Concurrent (forkIO)+import Control.Concurrent.Thread as Thread (Result(..))+import Control.Concurrent.Thread.Group as ThreadGroup (new, forkIO, wait)+ import qualified System.IO as IO import qualified System.Directory as D @@ -194,11 +198,19 @@ -- | Applies a `Diff` to a directory. Throws an exception if the -- application fails. applyToDirectory :: Diff -> FilePath -> IO ()-applyToDirectory (Diff filediffs) filepath = mapM_ apply filediffs+applyToDirectory (Diff filediffs) filepath+ = void $ mapMParallelWaitForAll (void . apply) filediffs where apply :: Filediff -> IO [Line] apply diff@(Filediff base compare _) = applyToFile diff (filepath </> base)++mapMParallelWaitForAll :: (a -> IO b) -> [a] -> IO [Thread.Result b]+mapMParallelWaitForAll f list = do+ group <- ThreadGroup.new+ ioResults <- mapM (fmap snd . ThreadGroup.forkIO group . f) list+ ThreadGroup.wait group+ sequence ioResults -- | Computes the minimal number of additions and deletions needed to -- transform the first parameter into the second.