diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-02-29 15:57:47 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-02-29 15:57:47 -0400 |
commit | 6d4ab4dc7389e2184d32962b751268125dfa56ae (patch) | |
tree | 9d3f29e122aa92e82d499580b4ffb84be8619eba | |
parent | 453ba048af869ed731e54f39b8b9db7d6859510a (diff) |
make assistant aware of adjusted branches when merging
-rw-r--r-- | Annex/AdjustedBranch.hs | 4 | ||||
-rw-r--r-- | Assistant/Threads/Merger.hs | 16 | ||||
-rw-r--r-- | Assistant/XMPP/Git.hs | 1 | ||||
-rw-r--r-- | Command/Sync.hs | 32 |
4 files changed, 30 insertions, 23 deletions
diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs index 1579a1f2f..8acaa0514 100644 --- a/Annex/AdjustedBranch.hs +++ b/Annex/AdjustedBranch.hs @@ -120,6 +120,6 @@ commitAdjustedTree treesha parent = go =<< catCommit parent {- Update the currently checked out adjusted branch, merging the provided - branch into it. -} -updateAdjustedBranch :: Adjustment -> OrigBranch -> Branch -> Annex Bool -updateAdjustedBranch mergebranch = do +updateAdjustedBranch :: Branch -> (OrigBranch, Adjustment) -> Git.Branch.CommitMode -> Annex Bool +updateAdjustedBranch tomerge (origbranch, adj) commitmode = do error "updateAdjustedBranch" diff --git a/Assistant/Threads/Merger.hs b/Assistant/Threads/Merger.hs index f1a64925d..35d02322d 100644 --- a/Assistant/Threads/Merger.hs +++ b/Assistant/Threads/Merger.hs @@ -17,7 +17,7 @@ import Utility.DirWatcher.Types import qualified Annex.Branch import qualified Git import qualified Git.Branch -import Annex.AutoMerge +import qualified Command.Sync import Annex.TaggedPush import Remote (remoteFromUUID) @@ -72,19 +72,21 @@ onChange file unlessM handleDesynced $ queueDeferredDownloads "retrying deferred download" Later | "/synced/" `isInfixOf` file = - mergecurrent =<< liftAnnex (inRepo Git.Branch.current) + mergecurrent =<< liftAnnex (join Command.Sync.getCurrBranch) | otherwise = noop where changedbranch = fileToBranch file - mergecurrent (Just current) - | equivBranches changedbranch current = - whenM (liftAnnex $ inRepo $ Git.Branch.changed current changedbranch) $ do + mergecurrent currbranch@(Just b, _) + | equivBranches changedbranch b = + whenM (liftAnnex $ inRepo $ Git.Branch.changed b changedbranch) $ do debug [ "merging", Git.fromRef changedbranch - , "into", Git.fromRef current + , "into", Git.fromRef b ] - void $ liftAnnex $ autoMergeFrom changedbranch (Just current) Git.Branch.AutomaticCommit + void $ liftAnnex $ Command.Sync.merge + currbranch Git.Branch.AutomaticCommit + changedbranch mergecurrent _ = noop handleDesynced = case fromTaggedBranch changedbranch of diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs index 9e0b9278b..286fcf879 100644 --- a/Assistant/XMPP/Git.hs +++ b/Assistant/XMPP/Git.hs @@ -27,7 +27,6 @@ import Annex.TaggedPush import Annex.CatFile import Config import Git -import qualified Git.Branch import qualified Types.Remote as Remote import qualified Remote as Remote import Remote.List diff --git a/Command/Sync.hs b/Command/Sync.hs index b362d7c1e..0d0358af9 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -10,6 +10,7 @@ module Command.Sync ( cmd, CurrBranch, getCurrBranch, + merge, prepMerge, mergeLocal, mergeRemote, @@ -165,6 +166,12 @@ getCurrBranch = do prepMerge :: Annex () prepMerge = Annex.changeDirectory =<< fromRepo Git.repoPath +merge :: CurrBranch -> Git.Branch.CommitMode -> Git.Branch -> Annex Bool +merge (Just b, Just adj) commitmode tomerge = + updateAdjustedBranch tomerge (b, adj) commitmode +merge (b, _) commitmode tomerge = + autoMergeFrom tomerge b commitmode + syncBranch :: Git.Ref -> Git.Ref syncBranch = Git.Ref.under "refs/heads/synced" . fromDirectBranch @@ -236,8 +243,7 @@ commitStaged commitmode commitmessage = do return True mergeLocal :: CurrBranch -> CommandStart -mergeLocal (Nothing, _) = stop -mergeLocal (Just branch, madj) = go =<< needmerge +mergeLocal currbranch@(Just branch, _) = go =<< needmerge where syncbranch = syncBranch branch needmerge = ifM isBareRepo @@ -250,9 +256,9 @@ mergeLocal (Just branch, madj) = go =<< needmerge go False = stop go True = do showStart "merge" $ Git.Ref.describe syncbranch - next $ next $ case madj of - Nothing -> autoMergeFrom syncbranch (Just branch) Git.Branch.ManualCommit - Just adj -> updateAdjustedBranch adj branch syncbranch + next $ next $ + merge currbranch Git.Branch.ManualCommit syncbranch +mergeLocal (Nothing, _) = stop pushLocal :: CurrBranch -> CommandStart pushLocal b = do @@ -298,19 +304,19 @@ pullRemote o remote branch = stopUnless (pure $ pullOption o) $ do - while the synced/master may have changes that some - other remote synced to this remote. So, merge them both. -} mergeRemote :: Remote -> CurrBranch -> CommandCleanup -mergeRemote remote b = ifM isBareRepo +mergeRemote remote currbranch = ifM isBareRepo ( return True - , case b of + , case currbranch of (Nothing, _) -> do branch <- inRepo Git.Branch.currentUnsafe - and <$> mapM (merge Nothing Nothing) (branchlist branch) - (Just currbranch, madj) -> do - inRepo $ updateBranch $ syncBranch currbranch - and <$> (mapM (merge (Just currbranch) madj) =<< tomerge (branchlist (Just currbranch))) + mergelisted (pure (branchlist branch)) + (Just branch, _) -> do + inRepo $ updateBranch $ syncBranch branch + mergelisted (tomerge (branchlist (Just branch))) ) where - merge (Just origbranch) (Just adj) br = updateAdjustedBranch adj origbranch br - merge currbranch _ br = autoMergeFrom (remoteBranch remote br) currbranch Git.Branch.ManualCommit + mergelisted getlist = and <$> + (mapM (merge currbranch Git.Branch.ManualCommit) =<< getlist) tomerge = filterM (changed remote) branchlist Nothing = [] branchlist (Just branch) = [branch, syncBranch branch] |