diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-24 16:13:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-24 16:13:22 -0400 |
commit | 5c49f7ef10b8d61cfabd8ca9602d852ae5abe452 (patch) | |
tree | 259f4088b02c3ed08d488572bfde314dec21b181 /Assistant/Types | |
parent | 6148b926959ce5cbbc12aafc60a119788ca6d97f (diff) |
use TList for ChangePool
Diffstat (limited to 'Assistant/Types')
-rw-r--r-- | Assistant/Types/Changes.hs | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/Assistant/Types/Changes.hs b/Assistant/Types/Changes.hs index 3b6e8501a..81fd527a6 100644 --- a/Assistant/Types/Changes.hs +++ b/Assistant/Types/Changes.hs @@ -1,6 +1,6 @@ {- git-annex assistant change tracking - - - Copyright 2012 Joey Hess <joey@kitenet.net> + - Copyright 2012-2013 Joey Hess <joey@kitenet.net> - - Licensed under the GNU GPL version 3 or higher. -} @@ -9,23 +9,22 @@ module Assistant.Types.Changes where import Types.KeySource import Types.Key -import Utility.TSet +import Utility.TList -import Data.Time.Clock import Control.Concurrent.STM +import Data.Time.Clock -data ChangeInfo = AddKeyChange Key | AddFileChange | LinkChange (Maybe Key) | RmChange - deriving (Show, Eq) - -changeInfoKey :: ChangeInfo -> Maybe Key -changeInfoKey (AddKeyChange k) = Just k -changeInfoKey (LinkChange (Just k)) = Just k -changeInfoKey _ = Nothing - -type ChangeChan = TSet [Change] +{- An un-ordered pool of Changes that have been noticed and should be + - staged and committed. Changes will typically be in order, but ordering + - may be lost. In any case, order should not matter, as any given Change + - may later be reverted by a later Change (ie, a file is added and then + - deleted). Code that processes the changes needs to deal with such + - scenarios. + -} +type ChangePool = TList Change -newChangeChan :: IO ChangeChan -newChangeChan = atomically newTSet +newChangePool :: IO ChangePool +newChangePool = atomically newTList data Change = Change @@ -43,6 +42,14 @@ data Change } deriving (Show) +data ChangeInfo = AddKeyChange Key | AddFileChange | LinkChange (Maybe Key) | RmChange + deriving (Show, Eq, Ord) + +changeInfoKey :: ChangeInfo -> Maybe Key +changeInfoKey (AddKeyChange k) = Just k +changeInfoKey (LinkChange (Just k)) = Just k +changeInfoKey _ = Nothing + changeFile :: Change -> FilePath changeFile (Change _ f _) = f changeFile (PendingAddChange _ f) = f |