split Changes and lifted
This commit is contained in:
parent
39a3adf434
commit
d2294f0dfa
5 changed files with 82 additions and 67 deletions
54
Assistant/Types/Changes.hs
Normal file
54
Assistant/Types/Changes.hs
Normal file
|
@ -0,0 +1,54 @@
|
|||
{- git-annex assistant change tracking
|
||||
-
|
||||
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
module Assistant.Types.Changes where
|
||||
|
||||
import Types.KeySource
|
||||
import Utility.TSet
|
||||
|
||||
import Data.Time.Clock
|
||||
|
||||
data ChangeType = AddChange | LinkChange | RmChange | RmDirChange
|
||||
deriving (Show, Eq)
|
||||
|
||||
type ChangeChan = TSet Change
|
||||
|
||||
data Change
|
||||
= Change
|
||||
{ changeTime :: UTCTime
|
||||
, changeFile :: FilePath
|
||||
, changeType :: ChangeType
|
||||
}
|
||||
| PendingAddChange
|
||||
{ changeTime ::UTCTime
|
||||
, changeFile :: FilePath
|
||||
}
|
||||
| InProcessAddChange
|
||||
{ changeTime ::UTCTime
|
||||
, keySource :: KeySource
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
newChangeChan :: IO ChangeChan
|
||||
newChangeChan = newTSet
|
||||
|
||||
isPendingAddChange :: Change -> Bool
|
||||
isPendingAddChange (PendingAddChange {}) = True
|
||||
isPendingAddChange _ = False
|
||||
|
||||
isInProcessAddChange :: Change -> Bool
|
||||
isInProcessAddChange (InProcessAddChange {}) = True
|
||||
isInProcessAddChange _ = False
|
||||
|
||||
finishedChange :: Change -> Change
|
||||
finishedChange c@(InProcessAddChange { keySource = ks }) = Change
|
||||
{ changeTime = changeTime c
|
||||
, changeFile = keyFilename ks
|
||||
, changeType = AddChange
|
||||
}
|
||||
finishedChange c = c
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue