]> code.delx.au - offlineimap/commitdiff
Rename ModifyContent to SetContent
authorJohn Goerzen <jgoerzen@complete.org>
Thu, 29 May 2008 08:32:45 +0000 (03:32 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Thu, 29 May 2008 08:32:45 +0000 (03:32 -0500)
src/Data/Syncable.hs
testsrc/runtests.hs

index 4eac9ee1e111460504c930fb3b12508c8b6bb909..313e0daf298c744093ac3e131b70c2225e2f3f2e 100644 (file)
@@ -72,7 +72,7 @@ data (Eq k, Ord k, Show k, Show v) =>
     SyncCommand k v = 
            DeleteItem k
          | CopyItem k v
-         | ModifyContent k v
+         | SetContent k v
     deriving (Eq, Ord, Show)
 
 pairToFunc :: (a -> b -> c) -> (a, b) -> c
@@ -110,13 +110,13 @@ syncBiDir masterstate childstate lastchildstate =
                           ++ 
                           (map (pairToFunc CopyItem) .
                            findAdded childstate masterstate $ lastchildstate)
-                          ++ (map (pairToFunc ModifyContent) . Map.toList $ masterPayloadChanges)
+                          ++ (map (pairToFunc SetContent) . Map.toList $ masterPayloadChanges)
           childchanges = (map DeleteItem . 
                           findDeleted masterstate childstate $ lastchildstate)
                          ++
                          (map (pairToFunc CopyItem) .
                           findAdded masterstate childstate $ lastchildstate)
-                         ++ (map (pairToFunc ModifyContent) . Map.toList $ childPayloadChanges)
+                         ++ (map (pairToFunc SetContent) . Map.toList $ childPayloadChanges)
           masterPayloadChanges = 
               Map.union 
                  (findModified masterstate childstate childstate lastchildstate)
@@ -143,7 +143,7 @@ diffCollection coll1 coll2 =
     (map (pairToFunc CopyItem) . findAdded coll2 coll1 $ coll1) ++
     modifiedData
     where modifiedData = 
-              map (pairToFunc ModifyContent) .
+              map (pairToFunc SetContent) .
               Map.toList . 
               Map.mapMaybe id .
               Map.intersectionWith compareFunc coll1 $ coll2
@@ -153,7 +153,7 @@ diffCollection coll1 coll2 =
               
                          
     {-
-    (map (pairToFunc ModifyContent) . Map.toList .
+    (map (pairToFunc SetContent) . Map.toList .
          findModified coll1 coll2 $ coll1)
      -}
 
@@ -213,18 +213,18 @@ unaryApplyChanges collection commands =
             Map.delete key collection
         makeChange collection (CopyItem key val) =
             Map.insert key val collection
-        makeChange collection (ModifyContent key val) =
+        makeChange collection (SetContent key val) =
             Map.adjust (\_ -> val) key collection
     in foldl makeChange collection commands
 
-{- | Given the base input and a ModifyContent command, convert this to
-commands to sync.  Ignores anything that is not a ModifyContent command
+{- | Given the base input and a SetContent command, convert this to
+commands to sync.  Ignores anything that is not a SetContent command
 by returning an empty list. -}
 modifyToSync :: (Eq k, Ord k, Show k, Eq v, Show v, Eq v', Show v', Ord v) =>
                 SyncCollection k (SyncCollection v v')
              -> SyncCommand k (SyncCollection v v')
              -> [SyncCommand v v']
-modifyToSync base (ModifyContent key val) =
+modifyToSync base (SetContent key val) =
     case Map.lookup key base of
       Nothing -> error $ "modifyToSync: attempt to modify on unknown base key " ++ show key
       Just basev ->
index 0b7f44aba397cb0bb42463f8a6a19af398f6503c..5c38314970cedac3b1951f7405e83efeb7c0162e 100644 (file)
@@ -63,7 +63,7 @@ prop_allChangesToChild master child =
         expectedResChild = sort $
             (map (\(k, v) -> CopyItem k v) . Map.toList . Map.difference master $ child) ++
             (map DeleteItem . Map.keys . Map.difference child $ master) ++
-            (map (pairToFunc ModifyContent) changeList)
+            (map (pairToFunc SetContent) changeList)
         changeList = foldl changefunc [] (Map.toList child)
         changefunc accum (k, v) =
             case Map.lookup k master of
@@ -80,7 +80,7 @@ prop_allChangesToMaster master child =
         expectedResMaster = sort $
             (map (pairToFunc CopyItem) . Map.toList . Map.difference child $ master) ++
             (map DeleteItem . Map.keys . Map.difference master $ child) ++
-            (map (pairToFunc ModifyContent) changeList)
+            (map (pairToFunc SetContent) changeList)
         changeList = foldl changefunc [] (Map.toList child)
         changefunc accum (k, v) =
             case Map.lookup k master of
@@ -131,12 +131,12 @@ prop_allChanges master child lastchild =
         expectedResMaster = sort $
             (map (pairToFunc CopyItem) . Map.toList . Map.difference child $ Map.union master lastchild) ++
                                                                                             (map DeleteItem . Map.keys . Map.intersection master $ Map.difference lastchild child) ++
-            (map (pairToFunc ModifyContent) masterMods)
+            (map (pairToFunc SetContent) masterMods)
 
         expectedResChild = sort $
             (map (pairToFunc CopyItem) . Map.toList . Map.difference master $ Map.union child lastchild) ++
                                                                                             (map DeleteItem . Map.keys . Map.intersection child $ Map.difference lastchild master) ++
-            (map (pairToFunc ModifyContent) childMods)
+            (map (pairToFunc SetContent) childMods)
 
     in (expectedResMaster, expectedResChild) @=?
        (sort resMaster, sort resChild)