fixup merges now done when needed
This commit is contained in:
parent
14015036bc
commit
05c4dfb941
3 changed files with 22 additions and 5 deletions
|
@ -70,3 +70,11 @@ onAdd g file _
|
||||||
|
|
||||||
mergeBranch :: Git.Ref -> Git.Repo -> IO Bool
|
mergeBranch :: Git.Ref -> Git.Repo -> IO Bool
|
||||||
mergeBranch = Git.Merge.mergeNonInteractive . Command.Sync.syncBranch
|
mergeBranch = Git.Merge.mergeNonInteractive . Command.Sync.syncBranch
|
||||||
|
|
||||||
|
{- Manually pull from remotes and merge their branches. Called by the pusher
|
||||||
|
- when a push fails, which can happen due to a remote not having pushed
|
||||||
|
- changes to us. That could be because it doesn't have us as a remote, or
|
||||||
|
- because the assistant is not running there, or other reasons. -}
|
||||||
|
manualPull :: Git.Ref -> [Remote] -> Annex ()
|
||||||
|
manualPull currentbranch remotes = forM_ remotes $ \r ->
|
||||||
|
Command.Sync.mergeRemote r currentbranch
|
||||||
|
|
|
@ -11,6 +11,7 @@ import Common.Annex
|
||||||
import Assistant.Commits
|
import Assistant.Commits
|
||||||
import Assistant.Pushes
|
import Assistant.Pushes
|
||||||
import Assistant.ThreadedMonad
|
import Assistant.ThreadedMonad
|
||||||
|
import Assistant.Threads.Merger
|
||||||
import qualified Command.Sync
|
import qualified Command.Sync
|
||||||
import Utility.ThreadScheduler
|
import Utility.ThreadScheduler
|
||||||
import Utility.Parallel
|
import Utility.Parallel
|
||||||
|
@ -68,11 +69,19 @@ pushToRemotes :: UTCTime -> ThreadState -> FailedPushChan -> [Remote] -> IO ()
|
||||||
pushToRemotes now st pushchan remotes = do
|
pushToRemotes now st pushchan remotes = do
|
||||||
(g, branch) <- runThreadState st $
|
(g, branch) <- runThreadState st $
|
||||||
(,) <$> fromRepo id <*> Command.Sync.currentBranch
|
(,) <$> fromRepo id <*> Command.Sync.currentBranch
|
||||||
Command.Sync.updateBranch (Command.Sync.syncBranch branch) g
|
go True branch g remotes
|
||||||
failed <- map (`FailedPush` now) <$> inParallel (push g branch) remotes
|
|
||||||
unless (null failed) $
|
|
||||||
refillFailedPushes pushchan failed
|
|
||||||
where
|
where
|
||||||
|
go shouldretry branch g rs = do
|
||||||
|
Command.Sync.updateBranch (Command.Sync.syncBranch branch) g
|
||||||
|
failed <- inParallel (push g branch) rs
|
||||||
|
unless (null failed) $
|
||||||
|
if shouldretry
|
||||||
|
then retry branch g rs
|
||||||
|
else refillFailedPushes pushchan $
|
||||||
|
map (`FailedPush` now) failed
|
||||||
push g branch remote =
|
push g branch remote =
|
||||||
ifM (Command.Sync.pushBranch remote branch g)
|
ifM (Command.Sync.pushBranch remote branch g)
|
||||||
( exitSuccess, exitFailure)
|
( exitSuccess, exitFailure)
|
||||||
|
retry branch g rs = do
|
||||||
|
runThreadState st $ manualPull branch rs
|
||||||
|
go False branch g rs
|
||||||
|
|
|
@ -15,7 +15,7 @@ all the other git clones, at both the git level and the key/value level.
|
||||||
**done**
|
**done**
|
||||||
1. Periodically retry pushes that failed. **done** (every half an hour)
|
1. Periodically retry pushes that failed. **done** (every half an hour)
|
||||||
1. Also, detect if a push failed due to not being up-to-date, pull,
|
1. Also, detect if a push failed due to not being up-to-date, pull,
|
||||||
and repush.
|
and repush. **done**
|
||||||
2. Use a git merge driver that adds both conflicting files,
|
2. Use a git merge driver that adds both conflicting files,
|
||||||
so conflicts never break a sync.
|
so conflicts never break a sync.
|
||||||
3. Investigate the XMPP approach like dvcs-autosync does, or other ways of
|
3. Investigate the XMPP approach like dvcs-autosync does, or other ways of
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue