summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-03 14:02:34 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-03 14:37:46 -0400
commit2607479890ac2b2a1bd63aca10dd87c9199bf414 (patch)
treed9422c5015740ff576b462fb50d303c557e4fc64 /Annex
parent0f2130f8f2a24af815315c3e9e79879cf900e7ea (diff)
lockJournal when running performTransitions
This may not strictly be needed -- the transition code bypasses the journal. However, this ensures that the git-annex branch is only committed with the journal locked. This will allow for further improvements.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Branch.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index b8c9d02e4..9dfdaa876 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -404,7 +404,8 @@ stageJournal = withIndex $ do
- remote refs cannot be merged into the branch (since transitions
- throw away history), so they are added to the list of refs to ignore,
- to avoid re-merging content from them again.
- -}
+ -
+ - Should be called only inside lockJournal. -}
handleTransitions :: Transitions -> [Git.Ref] -> Annex Bool
handleTransitions localts refs = do
m <- M.fromList <$> mapM getreftransition refs
@@ -415,7 +416,7 @@ handleTransitions localts refs = do
let allts = combineTransitions (localts:remotets)
let (transitionedrefs, untransitionedrefs) =
partition (\r -> M.lookup r m == Just allts) refs
- performTransitions allts (localts /= allts) transitionedrefs
+ performTransitionsLocked allts (localts /= allts) transitionedrefs
ignoreRefs untransitionedrefs
return True
where
@@ -440,9 +441,13 @@ getIgnoredRefs = S.fromList . mapMaybe Git.Sha.extractSha . lines <$> content
liftIO $ catchDefaultIO "" $ readFile f
{- Performs the specified transitions on the contents of the index file,
- - commits it to the branch, or creates a new branch. -}
+ - commits it to the branch, or creates a new branch.
+ -}
performTransitions :: Transitions -> Bool -> [Ref] -> Annex ()
-performTransitions ts neednewlocalbranch transitionedrefs = do
+performTransitions ts neednewlocalbranch transitionedrefs = lockJournal $
+ performTransitionsLocked ts neednewlocalbranch transitionedrefs
+performTransitionsLocked :: Transitions -> Bool -> [Ref] -> Annex ()
+performTransitionsLocked ts neednewlocalbranch transitionedrefs = do
-- For simplicity & speed, we're going to use the Annex.Queue to
-- update the git-annex branch, while it usually holds changes
-- for the head branch. Flush any such changes.