rebase on top of updated original branch

This commit is contained in:
Joey Hess 2016-03-03 17:00:48 -04:00
parent ac08f6580e
commit 5e3f707c34
Failed to extract signature

View file

@ -219,19 +219,25 @@ updateAdjustedBranch tomerge (origbranch, adj) commitmode =
-} -}
propigateAdjustedCommits :: OrigBranch -> (Adjustment, AdjBranch) -> Annex () propigateAdjustedCommits :: OrigBranch -> (Adjustment, AdjBranch) -> Annex ()
propigateAdjustedCommits origbranch (adj, currbranch) = do propigateAdjustedCommits origbranch (adj, currbranch) = do
v <- inRepo $ Git.Ref.sha (Git.Ref.under "refs/heads" origbranch) ov <- inRepo $ Git.Ref.sha (Git.Ref.under "refs/heads" origbranch)
case v of case ov of
Just origsha -> preventCommits $ Just origsha -> preventCommits $ do
go origsha False =<< newcommits cv <- catCommit currbranch
case cv of
Just currcommit ->
newcommits
>>= go origsha False
>>= rebase currcommit
Nothing -> return ()
Nothing -> return () Nothing -> return ()
where where
newcommits = inRepo $ Git.Branch.changedCommits origbranch currbranch newcommits = inRepo $ Git.Branch.changedCommits origbranch currbranch
-- Get commits oldest first, so they can be processed -- Get commits oldest first, so they can be processed
-- in order made. -- in order made.
[Param "--reverse"] [Param "--reverse"]
go newhead _ [] = do go parent _ [] = do
inRepo $ Git.Branch.update origbranch newhead inRepo $ Git.Branch.update origbranch parent
-- TODO rebase adjusted branch return parent
go parent pastadjcommit (sha:l) = do go parent pastadjcommit (sha:l) = do
mc <- catCommit sha mc <- catCommit sha
case mc of case mc of
@ -242,6 +248,12 @@ propigateAdjustedCommits origbranch (adj, currbranch) = do
commit <- reverseAdjustedCommit parent adj c commit <- reverseAdjustedCommit parent adj c
go commit pastadjcommit l go commit pastadjcommit l
_ -> go parent pastadjcommit l _ -> go parent pastadjcommit l
rebase currcommit newparent = do
-- Reuse the current adjusted tree,
-- and reparent it on top of the new
-- version of the origbranch.
commitAdjustedTree (commitTree currcommit) newparent
>>= inRepo . Git.Branch.update currbranch
{- Reverses an adjusted commit, yielding a commit sha. {- Reverses an adjusted commit, yielding a commit sha.
- -