diff options
author | Joey Hess <joey@kitenet.net> | 2014-07-10 00:32:23 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-07-10 00:32:23 -0400 |
commit | c42733876bcb72d1b4c85de6bac73f1c73b216ad (patch) | |
tree | c3edc52aa7b5b90594def0cd9eb7d4d1b8fc12d2 /Annex/Direct.hs | |
parent | 200b8d462e46db7b6bb87ab832529199fff58247 (diff) |
refactor locking
Diffstat (limited to 'Annex/Direct.hs')
-rw-r--r-- | Annex/Direct.hs | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/Annex/Direct.hs b/Annex/Direct.hs index 9a305aab4..fdc67a720 100644 --- a/Annex/Direct.hs +++ b/Annex/Direct.hs @@ -5,8 +5,6 @@ - Licensed under the GNU GPL version 3 or higher. -} -{-# LANGUAGE CPP #-} - module Annex.Direct where import Common.Annex @@ -38,9 +36,7 @@ import Annex.Exception import Annex.VariantFile import Git.Index import Annex.Index -#ifdef mingw32_HOST_OS -import Utility.WinLock -#endif +import Annex.LockFile {- Uses git ls-files to find files that need to be committed, and stages - them into the index. Returns True if some changes were staged. -} @@ -164,7 +160,7 @@ addDirect file cache = do - normally. -} mergeDirect :: Maybe Git.Ref -> Maybe Git.Ref -> Git.Branch -> Annex Bool -> Git.Branch.CommitMode -> Annex Bool -mergeDirect startbranch oldref branch resolvemerge commitmode = lockMerge $ do +mergeDirect startbranch oldref branch resolvemerge commitmode = exclusively $ do reali <- fromRepo indexFile tmpi <- fromRepo indexFileLock liftIO $ copyFile reali tmpi @@ -186,24 +182,8 @@ mergeDirect startbranch oldref branch resolvemerge commitmode = lockMerge $ do liftIO $ rename tmpi reali return r - -lockMerge :: Annex a -> Annex a -lockMerge a = do - lockfile <- fromRepo gitAnnexMergeLock - createAnnexDirectory $ takeDirectory lockfile - mode <- annexFileMode - bracketIO (lock lockfile mode) unlock (const a) where -#ifndef mingw32_HOST_OS - lock lockfile mode = do - l <- noUmask mode $ createFile lockfile mode - waitToSetLock l (WriteLock, AbsoluteSeek, 0, 0) - return l - unlock = closeFd -#else - lock lockfile _mode = waitToLock $ lockExclusive lockfile - unlock = dropLock -#endif + exclusively = withExclusiveLock gitAnnexMergeLock {- Stage a merge into the index, avoiding changing HEAD or the current - branch. -} |