diff options
author | Joey Hess <joey@kitenet.net> | 2013-10-03 14:02:34 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-10-03 14:37:46 -0400 |
commit | 2607479890ac2b2a1bd63aca10dd87c9199bf414 (patch) | |
tree | d9422c5015740ff576b462fb50d303c557e4fc64 | |
parent | 0f2130f8f2a24af815315c3e9e79879cf900e7ea (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.
-rw-r--r-- | Annex/Branch.hs | 13 | ||||
-rw-r--r-- | Locations.hs | 3 |
2 files changed, 11 insertions, 5 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. diff --git a/Locations.hs b/Locations.hs index b05cdc076..2e9fd574a 100644 --- a/Locations.hs +++ b/Locations.hs @@ -223,7 +223,8 @@ gitAnnexJournalLock r = gitAnnexDir r </> "journal.lck" gitAnnexIndex :: Git.Repo -> FilePath gitAnnexIndex r = gitAnnexDir r </> "index" -{- Lock file for .git/annex/index. -} +{- Lock file for .git/annex/index. Not to be confused with git's + - index.lock. -} gitAnnexIndexLock :: Git.Repo -> FilePath gitAnnexIndexLock r = gitAnnexDir r </> "index.lck" |