make assistant aware of adjusted branches when merging
This commit is contained in:
parent
c1d7a5b97c
commit
048d513233
4 changed files with 30 additions and 23 deletions
|
@ -120,6 +120,6 @@ commitAdjustedTree treesha parent = go =<< catCommit parent
|
||||||
|
|
||||||
{- Update the currently checked out adjusted branch, merging the provided
|
{- Update the currently checked out adjusted branch, merging the provided
|
||||||
- branch into it. -}
|
- branch into it. -}
|
||||||
updateAdjustedBranch :: Adjustment -> OrigBranch -> Branch -> Annex Bool
|
updateAdjustedBranch :: Branch -> (OrigBranch, Adjustment) -> Git.Branch.CommitMode -> Annex Bool
|
||||||
updateAdjustedBranch mergebranch = do
|
updateAdjustedBranch tomerge (origbranch, adj) commitmode = do
|
||||||
error "updateAdjustedBranch"
|
error "updateAdjustedBranch"
|
||||||
|
|
|
@ -17,7 +17,7 @@ import Utility.DirWatcher.Types
|
||||||
import qualified Annex.Branch
|
import qualified Annex.Branch
|
||||||
import qualified Git
|
import qualified Git
|
||||||
import qualified Git.Branch
|
import qualified Git.Branch
|
||||||
import Annex.AutoMerge
|
import qualified Command.Sync
|
||||||
import Annex.TaggedPush
|
import Annex.TaggedPush
|
||||||
import Remote (remoteFromUUID)
|
import Remote (remoteFromUUID)
|
||||||
|
|
||||||
|
@ -72,19 +72,21 @@ onChange file
|
||||||
unlessM handleDesynced $
|
unlessM handleDesynced $
|
||||||
queueDeferredDownloads "retrying deferred download" Later
|
queueDeferredDownloads "retrying deferred download" Later
|
||||||
| "/synced/" `isInfixOf` file =
|
| "/synced/" `isInfixOf` file =
|
||||||
mergecurrent =<< liftAnnex (inRepo Git.Branch.current)
|
mergecurrent =<< liftAnnex (join Command.Sync.getCurrBranch)
|
||||||
| otherwise = noop
|
| otherwise = noop
|
||||||
where
|
where
|
||||||
changedbranch = fileToBranch file
|
changedbranch = fileToBranch file
|
||||||
|
|
||||||
mergecurrent (Just current)
|
mergecurrent currbranch@(Just b, _)
|
||||||
| equivBranches changedbranch current =
|
| equivBranches changedbranch b =
|
||||||
whenM (liftAnnex $ inRepo $ Git.Branch.changed current changedbranch) $ do
|
whenM (liftAnnex $ inRepo $ Git.Branch.changed b changedbranch) $ do
|
||||||
debug
|
debug
|
||||||
[ "merging", Git.fromRef changedbranch
|
[ "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
|
mergecurrent _ = noop
|
||||||
|
|
||||||
handleDesynced = case fromTaggedBranch changedbranch of
|
handleDesynced = case fromTaggedBranch changedbranch of
|
||||||
|
|
|
@ -27,7 +27,6 @@ import Annex.TaggedPush
|
||||||
import Annex.CatFile
|
import Annex.CatFile
|
||||||
import Config
|
import Config
|
||||||
import Git
|
import Git
|
||||||
import qualified Git.Branch
|
|
||||||
import qualified Types.Remote as Remote
|
import qualified Types.Remote as Remote
|
||||||
import qualified Remote as Remote
|
import qualified Remote as Remote
|
||||||
import Remote.List
|
import Remote.List
|
||||||
|
|
|
@ -10,6 +10,7 @@ module Command.Sync (
|
||||||
cmd,
|
cmd,
|
||||||
CurrBranch,
|
CurrBranch,
|
||||||
getCurrBranch,
|
getCurrBranch,
|
||||||
|
merge,
|
||||||
prepMerge,
|
prepMerge,
|
||||||
mergeLocal,
|
mergeLocal,
|
||||||
mergeRemote,
|
mergeRemote,
|
||||||
|
@ -165,6 +166,12 @@ getCurrBranch = do
|
||||||
prepMerge :: Annex ()
|
prepMerge :: Annex ()
|
||||||
prepMerge = Annex.changeDirectory =<< fromRepo Git.repoPath
|
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 -> Git.Ref
|
||||||
syncBranch = Git.Ref.under "refs/heads/synced" . fromDirectBranch
|
syncBranch = Git.Ref.under "refs/heads/synced" . fromDirectBranch
|
||||||
|
|
||||||
|
@ -236,8 +243,7 @@ commitStaged commitmode commitmessage = do
|
||||||
return True
|
return True
|
||||||
|
|
||||||
mergeLocal :: CurrBranch -> CommandStart
|
mergeLocal :: CurrBranch -> CommandStart
|
||||||
mergeLocal (Nothing, _) = stop
|
mergeLocal currbranch@(Just branch, _) = go =<< needmerge
|
||||||
mergeLocal (Just branch, madj) = go =<< needmerge
|
|
||||||
where
|
where
|
||||||
syncbranch = syncBranch branch
|
syncbranch = syncBranch branch
|
||||||
needmerge = ifM isBareRepo
|
needmerge = ifM isBareRepo
|
||||||
|
@ -250,9 +256,9 @@ mergeLocal (Just branch, madj) = go =<< needmerge
|
||||||
go False = stop
|
go False = stop
|
||||||
go True = do
|
go True = do
|
||||||
showStart "merge" $ Git.Ref.describe syncbranch
|
showStart "merge" $ Git.Ref.describe syncbranch
|
||||||
next $ next $ case madj of
|
next $ next $
|
||||||
Nothing -> autoMergeFrom syncbranch (Just branch) Git.Branch.ManualCommit
|
merge currbranch Git.Branch.ManualCommit syncbranch
|
||||||
Just adj -> updateAdjustedBranch adj branch syncbranch
|
mergeLocal (Nothing, _) = stop
|
||||||
|
|
||||||
pushLocal :: CurrBranch -> CommandStart
|
pushLocal :: CurrBranch -> CommandStart
|
||||||
pushLocal b = do
|
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
|
- while the synced/master may have changes that some
|
||||||
- other remote synced to this remote. So, merge them both. -}
|
- other remote synced to this remote. So, merge them both. -}
|
||||||
mergeRemote :: Remote -> CurrBranch -> CommandCleanup
|
mergeRemote :: Remote -> CurrBranch -> CommandCleanup
|
||||||
mergeRemote remote b = ifM isBareRepo
|
mergeRemote remote currbranch = ifM isBareRepo
|
||||||
( return True
|
( return True
|
||||||
, case b of
|
, case currbranch of
|
||||||
(Nothing, _) -> do
|
(Nothing, _) -> do
|
||||||
branch <- inRepo Git.Branch.currentUnsafe
|
branch <- inRepo Git.Branch.currentUnsafe
|
||||||
and <$> mapM (merge Nothing Nothing) (branchlist branch)
|
mergelisted (pure (branchlist branch))
|
||||||
(Just currbranch, madj) -> do
|
(Just branch, _) -> do
|
||||||
inRepo $ updateBranch $ syncBranch currbranch
|
inRepo $ updateBranch $ syncBranch branch
|
||||||
and <$> (mapM (merge (Just currbranch) madj) =<< tomerge (branchlist (Just currbranch)))
|
mergelisted (tomerge (branchlist (Just branch)))
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
merge (Just origbranch) (Just adj) br = updateAdjustedBranch adj origbranch br
|
mergelisted getlist = and <$>
|
||||||
merge currbranch _ br = autoMergeFrom (remoteBranch remote br) currbranch Git.Branch.ManualCommit
|
(mapM (merge currbranch Git.Branch.ManualCommit) =<< getlist)
|
||||||
tomerge = filterM (changed remote)
|
tomerge = filterM (changed remote)
|
||||||
branchlist Nothing = []
|
branchlist Nothing = []
|
||||||
branchlist (Just branch) = [branch, syncBranch branch]
|
branchlist (Just branch) = [branch, syncBranch branch]
|
||||||
|
|
Loading…
Add table
Reference in a new issue