2010-11-09 19:59:49 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Lock where
|
|
|
|
|
|
|
|
import Control.Monad.State (liftIO)
|
|
|
|
import System.Directory
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import Messages
|
2011-05-31 18:50:41 +00:00
|
|
|
import qualified AnnexQueue
|
2011-08-22 20:14:12 +00:00
|
|
|
import Utility.SafeCommand
|
2010-12-30 19:06:26 +00:00
|
|
|
|
|
|
|
command :: [Command]
|
2011-03-19 22:58:49 +00:00
|
|
|
command = [repoCommand "lock" paramPath seek "undo unlock command"]
|
2010-11-09 19:59:49 +00:00
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
seek :: [CommandSeek]
|
2011-05-31 18:58:06 +00:00
|
|
|
seek = [withFilesUnlocked start, withFilesUnlockedToBeCommitted start]
|
2010-11-11 22:54:52 +00:00
|
|
|
|
2010-11-09 19:59:49 +00:00
|
|
|
{- Undo unlock -}
|
2010-12-30 18:19:16 +00:00
|
|
|
start :: CommandStartBackendFile
|
2010-11-11 21:58:55 +00:00
|
|
|
start (file, _) = do
|
|
|
|
showStart "lock" file
|
2011-05-15 06:02:46 +00:00
|
|
|
next $ perform file
|
2010-11-09 19:59:49 +00:00
|
|
|
|
2010-12-30 18:19:16 +00:00
|
|
|
perform :: FilePath -> CommandPerform
|
2010-11-09 19:59:49 +00:00
|
|
|
perform file = do
|
|
|
|
liftIO $ removeFile file
|
2011-05-31 18:50:41 +00:00
|
|
|
-- Checkout from HEAD to get rid of any changes that might be
|
|
|
|
-- staged in the index, and get back to the previous symlink to
|
|
|
|
-- the content.
|
2011-07-14 20:56:06 +00:00
|
|
|
AnnexQueue.add "checkout" [Param "HEAD", Param "--"] [file]
|
2011-05-15 06:02:46 +00:00
|
|
|
next $ return True -- no cleanup needed
|