2010-11-09 15:59:49 -04:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2010 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Lock where
|
|
|
|
|
2011-10-05 16:02:51 -04:00
|
|
|
import Common.Annex
|
2010-11-09 15:59:49 -04:00
|
|
|
import Command
|
2011-10-04 00:40:47 -04:00
|
|
|
import qualified Annex.Queue
|
2010-12-30 15:06:26 -04:00
|
|
|
|
2011-10-29 15:19:05 -04:00
|
|
|
def :: [Command]
|
|
|
|
def = [command "lock" paramPaths seek "undo unlock command"]
|
2010-11-09 15:59:49 -04:00
|
|
|
|
2010-12-30 14:19:16 -04:00
|
|
|
seek :: [CommandSeek]
|
2011-05-31 14:58:06 -04:00
|
|
|
seek = [withFilesUnlocked start, withFilesUnlockedToBeCommitted start]
|
2010-11-11 18:54:52 -04:00
|
|
|
|
2012-02-13 23:42:44 -04:00
|
|
|
start :: FilePath -> CommandStart
|
|
|
|
start file = do
|
2010-11-11 17:58:55 -04:00
|
|
|
showStart "lock" file
|
2011-05-15 02:02:46 -04:00
|
|
|
next $ perform file
|
2010-11-09 15:59:49 -04:00
|
|
|
|
2010-12-30 14:19:16 -04:00
|
|
|
perform :: FilePath -> CommandPerform
|
2010-11-09 15:59:49 -04:00
|
|
|
perform file = do
|
|
|
|
liftIO $ removeFile file
|
2011-05-31 14:50:41 -04: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-10-04 00:40:47 -04:00
|
|
|
Annex.Queue.add "checkout" [Param "HEAD", Param "--"] [file]
|
2011-05-15 02:02:46 -04:00
|
|
|
next $ return True -- no cleanup needed
|