Browse files

Updated to use Diff 0.2. Version bump to 0.6.

API change:  Diff instead of DI.
  • Loading branch information...
1 parent 34d06ac commit 5ed6c3d014e9ffdeafed6d18a2c777d9dac91937 John MacFarlane committed Dec 31, 2012
Showing with 10 additions and 10 deletions.
  1. +5 −5 Data/FileStore/Generic.hs
  2. +2 −2 filestore.cabal
  3. +3 −3 tests/Tests.lhs
View
10 Data/FileStore/Generic.hs
@@ -14,7 +14,7 @@
module Data.FileStore.Generic
( modify
, create
- , DI(..)
+ , Diff(..)
, diff
, searchRevisions
, smartRetrieve
@@ -27,7 +27,7 @@ import Data.FileStore.Types
import Control.Exception (throwIO, catch, SomeException, try)
import Data.FileStore.Utils
import Data.List (isInfixOf)
-import Data.Algorithm.Diff (DI(..), getGroupedDiff)
+import Data.Algorithm.Diff (Diff(..), getGroupedDiff)
import System.FilePath ((</>))
import Prelude hiding (catch)
@@ -73,18 +73,18 @@ modify fs name originalRevId author msg contents = do
return $ Left (MergeInfo latestRev conflicts mergedText)
-- | Return a unified diff of two revisions of a named resource.
--- Format of the diff is a list @[(DI, [String])]@, where
+-- Format of the diff is a list @[(Diff, [String])]@, where
-- @DI@ is @F@ (in first document only), @S@ (in second only),
-- or @B@ (in both), and the list is a list of lines (without
-- newlines at the end).
diff :: FileStore
-> FilePath -- ^ Resource name to get diff for.
-> Maybe RevisionId -- ^ @Just@ old revision ID, or @Nothing@ for empty.
-> Maybe RevisionId -- ^ @Just@ oew revision ID, or @Nothing@ for latest.
- -> IO [(DI, [String])]
+ -> IO [Diff [String]]
diff fs name Nothing id2 = do
contents2 <- retrieve fs name id2
- return [(S, lines contents2)] -- no need to run getGroupedDiff here - diff vs empty document
+ return [Second (lines contents2) ] -- no need to run getGroupedDiff here - diff vs empty document
diff fs name id1 id2 = do
contents1 <- retrieve fs name id1
contents2 <- retrieve fs name id2
View
4 filestore.cabal
@@ -1,5 +1,5 @@
Name: filestore
-Version: 0.5.0.1
+Version: 0.6
Cabal-version: >= 1.8
Build-type: Custom
Synopsis: Interface for versioning file stores.
@@ -43,7 +43,7 @@ Library
time >= 1.1 && < 1.5,
xml >= 1.3 && < 1.4,
split >= 0.1 && < 0.3,
- Diff >= 0.1.2 && < 0.2,
+ Diff >= 0.2 && < 0.3,
old-locale >= 1.0 && < 1.1
Exposed-modules: Data.FileStore, Data.FileStore.Types, Data.FileStore.Git, Data.FileStore.Darcs, Data.FileStore.Mercurial,
View
6 tests/Tests.lhs
@@ -12,7 +12,7 @@ This program runs tests for the filestore modules.
> import Data.Time
> import Data.Maybe (mapMaybe)
> import System.FilePath
-> import Data.Algorithm.Diff (DI(..))
+> import Data.Algorithm.Diff (Diff(..))
> main = do
> testFileStore (gitFileStore "tmp/gitfs") "Data.FileStore.Git"
@@ -338,13 +338,13 @@ This program runs tests for the filestore modules.
> [secondrev, firstrev] <- history fs [diffTitle] (TimeRange Nothing Nothing) Nothing
> diff' <- diff fs diffTitle (Just $ revId firstrev) (Just $ revId secondrev)
-> let subtracted' = mapMaybe (\(d,s) -> if d == F then Just s else Nothing) diff'
+> let subtracted' = [s | First s <- diff']
> assertEqual "subtracted lines" [[last (lines testContents)]] subtracted'
Diff from Nothing should be diff from empty document.
> diff'' <- diff fs diffTitle Nothing (Just $ revId firstrev)
-> let added'' = mapMaybe (\(d,s) -> if d == S then Just s else Nothing) diff''
+> let added'' = [s | Second s <- diff']
> assertEqual "added lines from empty document to first revision" [lines testContents] added''
Diff to Nothing should be diff to latest.

0 comments on commit 5ed6c3d

Please sign in to comment.