aboutsummaryrefslogtreecommitdiff
path: root/Annex/AdjustedBranch.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-03-03 17:00:48 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-03-03 17:00:48 -0400
commit028916acae51217b27de59d19f70ecc24cc2ed36 (patch)
treea224ffd8b12a6915f52808486ac31348a62013cf /Annex/AdjustedBranch.hs
parent73403cff30a5b6d9d4578a2709cf61b9c8cb945a (diff)
rebase on top of updated original branch
Diffstat (limited to 'Annex/AdjustedBranch.hs')
-rw-r--r--Annex/AdjustedBranch.hs26
1 files changed, 19 insertions, 7 deletions
diff --git a/Annex/AdjustedBranch.hs b/Annex/AdjustedBranch.hs
index 3c53ea924..208b976cd 100644
--- a/Annex/AdjustedBranch.hs
+++ b/Annex/AdjustedBranch.hs
@@ -219,19 +219,25 @@ updateAdjustedBranch tomerge (origbranch, adj) commitmode =
-}
propigateAdjustedCommits :: OrigBranch -> (Adjustment, AdjBranch) -> Annex ()
propigateAdjustedCommits origbranch (adj, currbranch) = do
- v <- inRepo $ Git.Ref.sha (Git.Ref.under "refs/heads" origbranch)
- case v of
- Just origsha -> preventCommits $
- go origsha False =<< newcommits
+ ov <- inRepo $ Git.Ref.sha (Git.Ref.under "refs/heads" origbranch)
+ case ov of
+ Just origsha -> preventCommits $ do
+ cv <- catCommit currbranch
+ case cv of
+ Just currcommit ->
+ newcommits
+ >>= go origsha False
+ >>= rebase currcommit
+ Nothing -> return ()
Nothing -> return ()
where
newcommits = inRepo $ Git.Branch.changedCommits origbranch currbranch
-- Get commits oldest first, so they can be processed
-- in order made.
[Param "--reverse"]
- go newhead _ [] = do
- inRepo $ Git.Branch.update origbranch newhead
- -- TODO rebase adjusted branch
+ go parent _ [] = do
+ inRepo $ Git.Branch.update origbranch parent
+ return parent
go parent pastadjcommit (sha:l) = do
mc <- catCommit sha
case mc of
@@ -242,6 +248,12 @@ propigateAdjustedCommits origbranch (adj, currbranch) = do
commit <- reverseAdjustedCommit parent adj c
go commit 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.
-