assistant: Fix one-way assistant->assistant sync in direct mode.

When in direct mode, update the master branch after committing to the
annex/direct/master branch. Also, update the synced/master branch.

This fixes a topology A->B where both A and B are in direct mode and
running the assistant, and a change is made to B. Before this fix, A pulled
the changes from B, but since they were only on the annex/direct/master
branch, it did not merge them.

Note that I considered making the assistant merge the
remotes/B/annex/direct/master, but decided to keep it simple and only merge
the sync branches as before.
This commit is contained in:
Joey Hess 2014-06-16 11:32:13 -04:00
parent 55870556df
commit 501cc8623a
5 changed files with 22 additions and 6 deletions

View file

@ -96,7 +96,7 @@ reconnectRemotes notifypushes rs = void $ do
=<< fromMaybe [] . M.lookup (Remote.uuid r) . connectRemoteNotifiers =<< fromMaybe [] . M.lookup (Remote.uuid r) . connectRemoteNotifiers
<$> getDaemonStatus <$> getDaemonStatus
{- Updates the local sync branch, then pushes it to all remotes, in {- Pushes the local sync branch to all remotes, in
- parallel, along with the git-annex branch. This is the same - parallel, along with the git-annex branch. This is the same
- as "git annex sync", except in parallel, and will co-exist with use of - as "git annex sync", except in parallel, and will co-exist with use of
- "git annex sync". - "git annex sync".
@ -148,7 +148,6 @@ pushToRemotes' now notifypushes remotes = do
go _ _ _ _ [] = return [] -- no remotes, so nothing to do go _ _ _ _ [] = return [] -- no remotes, so nothing to do
go shouldretry (Just branch) g u rs = do go shouldretry (Just branch) g u rs = do
debug ["pushing to", show rs] debug ["pushing to", show rs]
liftIO $ Command.Sync.updateBranch (Command.Sync.syncBranch branch) g
(succeeded, failed) <- liftIO $ inParallel (push g branch) rs (succeeded, failed) <- liftIO $ inParallel (push g branch) rs
updatemap succeeded [] updatemap succeeded []
if null failed if null failed

View file

@ -35,6 +35,7 @@ import qualified Annex
import Utility.InodeCache import Utility.InodeCache
import Annex.Content.Direct import Annex.Content.Direct
import qualified Command.Sync import qualified Command.Sync
import qualified Git.Branch
import Data.Time.Clock import Data.Time.Clock
import Data.Tuple.Utils import Data.Tuple.Utils
@ -219,7 +220,11 @@ commitStaged = do
v <- tryAnnex Annex.Queue.flush v <- tryAnnex Annex.Queue.flush
case v of case v of
Left _ -> return False Left _ -> return False
Right _ -> Command.Sync.commitStaged "" Right _ -> do
ok <- Command.Sync.commitStaged ""
when ok $
Command.Sync.updateSyncBranch =<< inRepo Git.Branch.current
return ok
{- OSX needs a short delay after a file is added before locking it down, {- OSX needs a short delay after a file is added before locking it down,
- when using a non-direct mode repository, as pasting a file seems to - when using a non-direct mode repository, as pasting a file seems to

View file

@ -172,8 +172,13 @@ mergeLocal (Just branch) = go =<< needmerge
next $ next $ autoMergeFrom syncbranch (Just branch) next $ next $ autoMergeFrom syncbranch (Just branch)
pushLocal :: Maybe Git.Ref -> CommandStart pushLocal :: Maybe Git.Ref -> CommandStart
pushLocal Nothing = stop pushLocal b = do
pushLocal (Just branch) = do updateSyncBranch b
stop
updateSyncBranch :: Maybe Git.Ref -> Annex ()
updateSyncBranch Nothing = noop
updateSyncBranch (Just branch) = do
-- Update the sync branch to match the new state of the branch -- Update the sync branch to match the new state of the branch
inRepo $ updateBranch $ syncBranch branch inRepo $ updateBranch $ syncBranch branch
-- In direct mode, we're operating on some special direct mode -- In direct mode, we're operating on some special direct mode
@ -181,7 +186,6 @@ pushLocal (Just branch) = do
-- branch. -- branch.
whenM isDirect $ whenM isDirect $
inRepo $ updateBranch $ fromDirectBranch branch inRepo $ updateBranch $ fromDirectBranch branch
stop
updateBranch :: Git.Ref -> Git.Repo -> IO () updateBranch :: Git.Ref -> Git.Repo -> IO ()
updateBranch syncbranch g = updateBranch syncbranch g =

6
debian/changelog vendored
View file

@ -1,3 +1,9 @@
git-annex (5.20140614) UNRELEASED; urgency=medium
* assistant: Fix one-way assistant->assistant sync in direct mode.
-- Joey Hess <joeyh@debian.org> Mon, 16 Jun 2014 11:28:42 -0400
git-annex (5.20140613) unstable; urgency=medium git-annex (5.20140613) unstable; urgency=medium
* Ignore setsid failures. * Ignore setsid failures.

View file

@ -5,3 +5,5 @@ When a change is made on A, the assistant commits it to annex/direct/master. But
B notices there is a change, pulls from A. Gets annex/direct/master, but does not merge it into its local branch at all. B notices there is a change, pulls from A. Gets annex/direct/master, but does not merge it into its local branch at all.
[[!tag confirmed]] [[!tag confirmed]]
> [[fixed|done]] --[[Joey]]