split Commits and lifted
This commit is contained in:
parent
d2294f0dfa
commit
42babf5012
7 changed files with 33 additions and 19 deletions
|
@ -7,25 +7,21 @@
|
||||||
|
|
||||||
module Assistant.Commits where
|
module Assistant.Commits where
|
||||||
|
|
||||||
|
import Assistant.Common
|
||||||
|
import Assistant.Types.Commits
|
||||||
|
|
||||||
import Utility.TSet
|
import Utility.TSet
|
||||||
|
|
||||||
type CommitChan = TSet Commit
|
|
||||||
|
|
||||||
data Commit = Commit
|
|
||||||
|
|
||||||
newCommitChan :: IO CommitChan
|
|
||||||
newCommitChan = newTSet
|
|
||||||
|
|
||||||
{- Gets all unhandled commits.
|
{- Gets all unhandled commits.
|
||||||
- Blocks until at least one commit is made. -}
|
- Blocks until at least one commit is made. -}
|
||||||
getCommits :: CommitChan -> IO [Commit]
|
getCommits :: Assistant [Commit]
|
||||||
getCommits = getTSet
|
getCommits = getTSet <<~ commitChan
|
||||||
|
|
||||||
{- Puts unhandled commits back into the channel.
|
{- Puts unhandled commits back into the channel.
|
||||||
- Note: Original order is not preserved. -}
|
- Note: Original order is not preserved. -}
|
||||||
refillCommits :: CommitChan -> [Commit] -> IO ()
|
refillCommits :: [Commit] -> Assistant ()
|
||||||
refillCommits = putTSet
|
refillCommits cs = flip putTSet cs <<~ commitChan
|
||||||
|
|
||||||
{- Records a commit in the channel. -}
|
{- Records a commit in the channel. -}
|
||||||
recordCommit :: CommitChan -> IO ()
|
recordCommit :: Assistant ()
|
||||||
recordCommit = flip putTSet1 Commit
|
recordCommit = flip putTSet1 Commit <<~ commitChan
|
||||||
|
|
|
@ -33,7 +33,7 @@ import Assistant.TransferQueue
|
||||||
import Assistant.TransferSlots
|
import Assistant.TransferSlots
|
||||||
import Assistant.Types.Pushes
|
import Assistant.Types.Pushes
|
||||||
import Assistant.Types.BranchChange
|
import Assistant.Types.BranchChange
|
||||||
import Assistant.Commits
|
import Assistant.Types.Commits
|
||||||
import Assistant.Types.Changes
|
import Assistant.Types.Changes
|
||||||
|
|
||||||
newtype Assistant a = Assistant { mkAssistant :: ReaderT AssistantData IO a }
|
newtype Assistant a = Assistant { mkAssistant :: ReaderT AssistantData IO a }
|
||||||
|
|
|
@ -61,7 +61,7 @@ commitThread = NamedThread "Committer" $ do
|
||||||
]
|
]
|
||||||
void $ alertWhile commitAlert $
|
void $ alertWhile commitAlert $
|
||||||
liftAnnex commitStaged
|
liftAnnex commitStaged
|
||||||
recordCommit <<~ commitChan
|
recordCommit
|
||||||
else refill readychanges
|
else refill readychanges
|
||||||
else refill changes
|
else refill changes
|
||||||
where
|
where
|
||||||
|
|
|
@ -48,7 +48,7 @@ configMonitorThread = NamedThread "ConfigMonitor" $ loop =<< getConfigs
|
||||||
reloadConfigs new
|
reloadConfigs new
|
||||||
{- Record a commit to get this config
|
{- Record a commit to get this config
|
||||||
- change pushed out to remotes. -}
|
- change pushed out to remotes. -}
|
||||||
recordCommit <<~ commitChan
|
recordCommit
|
||||||
loop new
|
loop new
|
||||||
|
|
||||||
{- Config files, and their checksums. -}
|
{- Config files, and their checksums. -}
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Assistant.Threads.Pusher where
|
||||||
|
|
||||||
import Assistant.Common
|
import Assistant.Common
|
||||||
import Assistant.Commits
|
import Assistant.Commits
|
||||||
|
import Assistant.Types.Commits
|
||||||
import Assistant.Pushes
|
import Assistant.Pushes
|
||||||
import Assistant.Alert
|
import Assistant.Alert
|
||||||
import Assistant.DaemonStatus
|
import Assistant.DaemonStatus
|
||||||
|
@ -41,7 +42,7 @@ pushThread :: NamedThread
|
||||||
pushThread = NamedThread "Pusher" $ runEvery (Seconds 2) <~> do
|
pushThread = NamedThread "Pusher" $ runEvery (Seconds 2) <~> do
|
||||||
-- We already waited two seconds as a simple rate limiter.
|
-- We already waited two seconds as a simple rate limiter.
|
||||||
-- Next, wait until at least one commit has been made
|
-- Next, wait until at least one commit has been made
|
||||||
commits <- getCommits <<~ commitChan
|
commits <- getCommits
|
||||||
-- Now see if now's a good time to push.
|
-- Now see if now's a good time to push.
|
||||||
if shouldPush commits
|
if shouldPush commits
|
||||||
then do
|
then do
|
||||||
|
@ -52,7 +53,7 @@ pushThread = NamedThread "Pusher" $ runEvery (Seconds 2) <~> do
|
||||||
pushToRemotes now True remotes
|
pushToRemotes now True remotes
|
||||||
else do
|
else do
|
||||||
debug ["delaying push of", show (length commits), "commits"]
|
debug ["delaying push of", show (length commits), "commits"]
|
||||||
flip refillCommits commits <<~ commitChan
|
refillCommits commits
|
||||||
where
|
where
|
||||||
pushable r
|
pushable r
|
||||||
| Remote.specialRemote r = False
|
| Remote.specialRemote r = False
|
||||||
|
|
|
@ -81,7 +81,7 @@ startTransfer program t info = case (transferRemote info, associatedFile info) o
|
||||||
liftIO $ void $ addAlert dstatus $
|
liftIO $ void $ addAlert dstatus $
|
||||||
makeAlertFiller True $
|
makeAlertFiller True $
|
||||||
transferFileAlert direction True file
|
transferFileAlert direction True file
|
||||||
recordCommit <<~ commitChan
|
recordCommit
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
[ Param "transferkey"
|
[ Param "transferkey"
|
||||||
|
|
17
Assistant/Types/Commits.hs
Normal file
17
Assistant/Types/Commits.hs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{- git-annex assistant commit tracking
|
||||||
|
-
|
||||||
|
- Copyright 2012 Joey Hess <joey@kitenet.net>
|
||||||
|
-
|
||||||
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Assistant.Types.Commits where
|
||||||
|
|
||||||
|
import Utility.TSet
|
||||||
|
|
||||||
|
type CommitChan = TSet Commit
|
||||||
|
|
||||||
|
data Commit = Commit
|
||||||
|
|
||||||
|
newCommitChan :: IO CommitChan
|
||||||
|
newCommitChan = newTSet
|
Loading…
Add table
Add a link
Reference in a new issue