made some progress on syncing adjusted branches, but still buggy
This commit is contained in:
parent
a585731935
commit
860602a1e6
3 changed files with 45 additions and 24 deletions
|
@ -222,28 +222,27 @@ adjustedBranchCommitMessage = "git-annex adjusted branch"
|
||||||
- branch into it. -}
|
- branch into it. -}
|
||||||
updateAdjustedBranch :: Branch -> (OrigBranch, Adjustment) -> Git.Branch.CommitMode -> Annex Bool
|
updateAdjustedBranch :: Branch -> (OrigBranch, Adjustment) -> Git.Branch.CommitMode -> Annex Bool
|
||||||
updateAdjustedBranch tomerge (origbranch, adj) commitmode = catchBoolIO $
|
updateAdjustedBranch tomerge (origbranch, adj) commitmode = catchBoolIO $
|
||||||
join $ preventCommits $ \commitsprevented -> go commitsprevented =<< (,)
|
join $ preventCommits $ \_ -> go =<< (,)
|
||||||
<$> inRepo (Git.Ref.sha tomerge)
|
<$> inRepo (Git.Ref.sha tomerge)
|
||||||
<*> inRepo Git.Branch.current
|
<*> inRepo Git.Branch.current
|
||||||
where
|
where
|
||||||
go commitsprevented (Just mergesha, Just currbranch) =
|
go (Just mergesha, Just currbranch) =
|
||||||
ifM (inRepo $ Git.Branch.changed currbranch mergesha)
|
ifM (inRepo $ Git.Branch.changed currbranch mergesha)
|
||||||
( do
|
( do
|
||||||
propigateAdjustedCommits' origbranch (adj, currbranch) commitsprevented
|
|
||||||
adjustedtomerge <- adjust adj mergesha
|
adjustedtomerge <- adjust adj mergesha
|
||||||
ifM (inRepo $ Git.Branch.changed currbranch adjustedtomerge)
|
ifM (inRepo $ Git.Branch.changed currbranch adjustedtomerge)
|
||||||
( return $ do
|
( return $
|
||||||
-- Run after commit lock is dropped.
|
-- Run after commit lock is dropped.
|
||||||
ifM (autoMergeFrom adjustedtomerge (Just currbranch) commitmode)
|
ifM (autoMergeFrom adjustedtomerge (Just currbranch) commitmode)
|
||||||
( preventCommits $ \commitsprevented' ->
|
( preventCommits $ \_ ->
|
||||||
recommit commitsprevented' currbranch mergesha =<< catCommit currbranch
|
recommit currbranch mergesha =<< catCommit currbranch
|
||||||
, return False
|
, return False
|
||||||
)
|
)
|
||||||
, nochangestomerge
|
, nochangestomerge
|
||||||
)
|
)
|
||||||
, nochangestomerge
|
, nochangestomerge
|
||||||
)
|
)
|
||||||
go _ _ = return $ return False
|
go _ = return $ return False
|
||||||
nochangestomerge = return $ return True
|
nochangestomerge = return $ return True
|
||||||
{- Once a merge commit has been made, re-do it, removing
|
{- Once a merge commit has been made, re-do it, removing
|
||||||
- the old version of the adjusted branch as a parent, and
|
- the old version of the adjusted branch as a parent, and
|
||||||
|
@ -251,13 +250,15 @@ updateAdjustedBranch tomerge (origbranch, adj) commitmode = catchBoolIO $
|
||||||
-
|
-
|
||||||
- Doing this ensures that the same commit Sha is
|
- Doing this ensures that the same commit Sha is
|
||||||
- always arrived at for a given commit from the merged in branch.
|
- always arrived at for a given commit from the merged in branch.
|
||||||
|
|
||||||
|
- Also, update the origbranch.
|
||||||
-}
|
-}
|
||||||
recommit commitsprevented 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 "merging into adjusted branch" currbranch commitsha
|
inRepo $ Git.Branch.update "updating original branch" origbranch parent
|
||||||
propigateAdjustedCommits' origbranch (adj, currbranch) commitsprevented
|
inRepo $ Git.Branch.update "rebasing adjusted branch on top of updated original branch after merge" currbranch commitsha
|
||||||
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 orig branch, and propigate them.
|
- been propigated to the orig branch, and propigate them.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{- git-annex command
|
{- git-annex command
|
||||||
-
|
-
|
||||||
- Copyright 2011 Joachim Breitner <mail@joachim-breitner.de>
|
- Copyright 2011 Joachim Breitner <mail@joachim-breitner.de>
|
||||||
- Copyright 2011-2014 Joey Hess <id@joeyh.name>
|
- Copyright 2011-2016 Joey Hess <id@joeyh.name>
|
||||||
-
|
-
|
||||||
- Licensed under the GNU GPL version 3 or higher.
|
- Licensed under the GNU GPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
@ -243,21 +243,28 @@ commitStaged commitmode commitmessage = do
|
||||||
return True
|
return True
|
||||||
|
|
||||||
mergeLocal :: CurrBranch -> CommandStart
|
mergeLocal :: CurrBranch -> CommandStart
|
||||||
mergeLocal currbranch@(Just branch, _) = go =<< needmerge
|
mergeLocal currbranch@(Just branch, madj) = do
|
||||||
|
proptoorig
|
||||||
|
go =<< needmerge
|
||||||
where
|
where
|
||||||
syncbranch = syncBranch branch
|
syncbranch = syncBranch branch
|
||||||
needmerge = ifM isBareRepo
|
needmerge = ifM isBareRepo
|
||||||
( return False
|
( return False
|
||||||
, ifM (inRepo $ Git.Ref.exists syncbranch)
|
, ifM (inRepo $ Git.Ref.exists syncbranch)
|
||||||
( inRepo $ Git.Branch.changed branch syncbranch
|
( inRepo $ Git.Branch.changed branch' syncbranch
|
||||||
, return False
|
, return False
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
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 $
|
next $ next $ merge currbranch Git.Branch.ManualCommit syncbranch
|
||||||
merge currbranch Git.Branch.ManualCommit syncbranch
|
branch' = maybe branch (originalToAdjusted branch) madj
|
||||||
|
-- When in an adjusted branch, propigate any changes made to it
|
||||||
|
-- back to the original branch.
|
||||||
|
proptoorig = case madj of
|
||||||
|
Just adj -> propigateAdjustedCommits branch (adj, branch')
|
||||||
|
Nothing -> return ()
|
||||||
mergeLocal (Nothing, _) = stop
|
mergeLocal (Nothing, _) = stop
|
||||||
|
|
||||||
pushLocal :: CurrBranch -> CommandStart
|
pushLocal :: CurrBranch -> CommandStart
|
||||||
|
@ -267,13 +274,7 @@ pushLocal b = do
|
||||||
|
|
||||||
updateSyncBranch :: CurrBranch -> Annex ()
|
updateSyncBranch :: CurrBranch -> Annex ()
|
||||||
updateSyncBranch (Nothing, _) = noop
|
updateSyncBranch (Nothing, _) = noop
|
||||||
updateSyncBranch (Just branch, madj) = do
|
updateSyncBranch (Just branch, _) = do
|
||||||
-- When in an adjusted branch, propigate any changes to it back to
|
|
||||||
-- the original branch.
|
|
||||||
case madj of
|
|
||||||
Just adj -> propigateAdjustedCommits branch
|
|
||||||
(adj, originalToAdjusted branch adj)
|
|
||||||
Nothing -> return ()
|
|
||||||
-- 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
|
||||||
|
|
|
@ -171,7 +171,7 @@ adjust that commit so it does not have adjusted/master as its parent.
|
||||||
|--------------->B''
|
|--------------->B''
|
||||||
| |
|
| |
|
||||||
|
|
||||||
Finally, update master, by reverse filtering B''. TODO
|
Finally, update master, by reverse filtering B''.
|
||||||
|
|
||||||
Notice how similar this is to the commit graph. So, "fast-forward"
|
Notice how similar this is to the commit graph. So, "fast-forward"
|
||||||
merging the same B commit from origin/master will lead to an identical
|
merging the same B commit from origin/master will lead to an identical
|
||||||
|
@ -301,3 +301,22 @@ into adjusted view worktrees.]
|
||||||
* Interface in webapp to enable adjustments.
|
* Interface in webapp to enable adjustments.
|
||||||
* Upgrade from direct mode to v6 in unlocked branch.
|
* Upgrade from direct mode to v6 in unlocked branch.
|
||||||
* Honor annex.thin when entering an adjusted branch.
|
* Honor annex.thin when entering an adjusted branch.
|
||||||
|
* Cloning a repo that has an adjusted branch checked out gets into an ugly
|
||||||
|
state.
|
||||||
|
|
||||||
|
Bug running git-annex sync in adjusted branch when there is a local change
|
||||||
|
that gets committed (or already has been), and remote changes available.
|
||||||
|
Both propigateAdjustedCommits and updateAdjustedBranch
|
||||||
|
get called in this scenario. Neither order of calling the two works entirely.
|
||||||
|
|
||||||
|
The reflog has:
|
||||||
|
|
||||||
|
d585d7f HEAD@{1}: rebasing adjusted branch on top of updated original branch
|
||||||
|
e51daec HEAD@{2}: merge f7f2b9f3b1d1c97a1ab24f4a94d4a27d84898992: Merge made by the 'recursive' strategy.
|
||||||
|
9504e7b HEAD@{3}: rebasing adjusted branch on top of updated original branch
|
||||||
|
6c6fd41 HEAD@{4}: commit: add
|
||||||
|
|
||||||
|
e51daec has ok correct history; it gets messed up in d585d7f
|
||||||
|
|
||||||
|
Problem is just, that the commit made to the adjusted branch
|
||||||
|
is left out of the history.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue