push original branch, not adjusted branch

This commit is contained in:
Joey Hess 2016-03-03 14:13:54 -04:00
parent 730b249477
commit 6024108ab2
Failed to extract signature
2 changed files with 22 additions and 11 deletions

View file

@ -10,8 +10,10 @@ module Annex.AdjustedBranch (
OrigBranch, OrigBranch,
AdjBranch, AdjBranch,
adjustedToOriginal, adjustedToOriginal,
fromAdjustedBranch,
enterAdjustedBranch, enterAdjustedBranch,
updateAdjustedBranch, updateAdjustedBranch,
propigateAdjustedCommits,
) where ) where
import Annex.Common import Annex.Common
@ -73,10 +75,11 @@ adjustedToOriginal b
bs = fromRef b bs = fromRef b
prefixlen = length adjustedBranchPrefix prefixlen = length adjustedBranchPrefix
fromAdjustedBranch :: Branch -> OrigBranch
fromAdjustedBranch b = maybe b snd (adjustedToOriginal b)
originalBranch :: Annex (Maybe OrigBranch) originalBranch :: Annex (Maybe OrigBranch)
originalBranch = fmap getorig <$> inRepo Git.Branch.current originalBranch = fmap fromAdjustedBranch <$> inRepo Git.Branch.current
where
getorig currbranch = maybe currbranch snd (adjustedToOriginal currbranch)
{- Enter an adjusted version of current branch (or, if already in an {- Enter an adjusted version of current branch (or, if already in an
- adjusted version of a branch, changes the adjustment of the original - adjusted version of a branch, changes the adjustment of the original
@ -173,10 +176,11 @@ updateAdjustedBranch tomerge (origbranch, adj) commitmode =
recommit currbranch parent (Just commit) = do recommit currbranch parent (Just commit) = do
commitsha <- commitAdjustedTree (commitTree commit) parent commitsha <- commitAdjustedTree (commitTree commit) parent
inRepo $ Git.Branch.update currbranch commitsha inRepo $ Git.Branch.update currbranch commitsha
propigateAdjustedCommits origbranch adj
return True return True
recommit _ _ Nothing = return False recommit _ _ Nothing = return False
{- Check for any commits present on the adjusted branch that have not yet {- Check for any commits present on the adjusted branch that have not yet
- been propigated to the master branch, and propigate them. -} - been propigated to the orig branch, and propigate them. -}
propigateAdjustedCommits :: OrigBranch -> Adjustment -> Annex () propigateAdjustedCommits :: OrigBranch -> Adjustment -> Annex ()
propigateAdjustedCommits originbranch adj = return () -- TODO propigateAdjustedCommits originbranch adj = return () -- TODO

View file

@ -172,8 +172,8 @@ merge (Just b, Just adj) commitmode tomerge =
merge (b, _) commitmode tomerge = merge (b, _) commitmode tomerge =
autoMergeFrom tomerge b commitmode autoMergeFrom tomerge b commitmode
syncBranch :: Git.Ref -> Git.Ref syncBranch :: Git.Branch -> Git.Branch
syncBranch = Git.Ref.under "refs/heads/synced" . fromDirectBranch syncBranch = Git.Ref.under "refs/heads/synced" . fromDirectBranch . fromAdjustedBranch
remoteBranch :: Remote -> Git.Ref -> Git.Ref remoteBranch :: Remote -> Git.Ref -> Git.Ref
remoteBranch remote = Git.Ref.underBase $ "refs/remotes/" ++ Remote.name remote remoteBranch remote = Git.Ref.underBase $ "refs/remotes/" ++ Remote.name remote
@ -268,13 +268,20 @@ pushLocal b = do
updateSyncBranch :: CurrBranch -> Annex () updateSyncBranch :: CurrBranch -> Annex ()
updateSyncBranch (Nothing, _) = noop updateSyncBranch (Nothing, _) = noop
updateSyncBranch (Just branch, _) = do updateSyncBranch (Just branch, _) = do
-- When in an adjusted branch, propigate any changes to it back to
-- the original branch.
branch' <- case adjustedToOriginal branch of
Just (adj, origbranch) -> do
propigateAdjustedCommits origbranch adj
return origbranch
Nothing -> return branch
-- 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) branch inRepo $ updateBranch (syncBranch branch') branch'
-- In direct mode, we're operating on some special direct mode -- In direct mode, we're operating on some special direct mode
-- branch, rather than the intended branch, so update the intended -- branch, rather than the intended branch, so update the intended
-- branch. -- branch.
whenM isDirect $ whenM isDirect $
inRepo $ updateBranch (fromDirectBranch branch) branch inRepo $ updateBranch (fromDirectBranch branch') branch'
updateBranch :: Git.Branch -> Git.Branch -> Git.Repo -> IO () updateBranch :: Git.Branch -> Git.Branch -> Git.Repo -> IO ()
updateBranch syncbranch updateto g = updateBranch syncbranch updateto g =
@ -368,16 +375,16 @@ pushRemote o remote (Just branch, _) = stopUnless (pure (pushOption o) <&&> need
- The sync push will fail to overwrite if receive.denyNonFastforwards is - The sync push will fail to overwrite if receive.denyNonFastforwards is
- set on the remote. - set on the remote.
-} -}
pushBranch :: Remote -> Git.Ref -> Git.Repo -> IO Bool pushBranch :: Remote -> Git.Branch -> Git.Repo -> IO Bool
pushBranch remote branch g = tryIO (directpush g) `after` syncpush g pushBranch remote branch g = tryIO (directpush g) `after` syncpush g
where where
syncpush = Git.Command.runBool $ pushparams syncpush = Git.Command.runBool $ pushparams
[ Git.Branch.forcePush $ refspec Annex.Branch.name [ Git.Branch.forcePush $ refspec Annex.Branch.name
, refspec branch , refspec $ fromAdjustedBranch branch
] ]
directpush = Git.Command.runQuiet $ pushparams directpush = Git.Command.runQuiet $ pushparams
[ Git.fromRef $ Git.Ref.base $ Annex.Branch.name [ Git.fromRef $ Git.Ref.base $ Annex.Branch.name
, Git.fromRef $ Git.Ref.base $ fromDirectBranch branch , Git.fromRef $ Git.Ref.base $ fromDirectBranch $ fromAdjustedBranch branch
] ]
pushparams branches = pushparams branches =
[ Param "push" [ Param "push"