git-annex/Command/Lock.hs

33 lines
881 B
Haskell
Raw Normal View History

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
2011-10-05 20:02:51 +00:00
import Common.Annex
2010-11-09 19:59:49 +00:00
import Command
2011-10-04 04:40:47 +00:00
import qualified Annex.Queue
2013-12-05 20:05:07 +00:00
import qualified Annex
def :: [Command]
def = [notDirect $ command "lock" paramPaths seek SectionCommon
"undo unlock command"]
2010-11-09 19:59:49 +00:00
seek :: [CommandSeek]
seek = [withFilesUnlocked start, withFilesUnlockedToBeCommitted start]
2010-11-11 22:54:52 +00:00
start :: FilePath -> CommandStart
start file = do
showStart "lock" file
2013-12-05 20:05:07 +00:00
unlessM (Annex.getState Annex.force) $
error "Locking this file would discard any changes you have made to it. Use 'git annex add' to stage your changes. (Or, use --force to override)"
2011-05-15 06:02:46 +00:00
next $ perform file
2010-11-09 19:59:49 +00:00
perform :: FilePath -> CommandPerform
2010-11-09 19:59:49 +00:00
perform file = do
Annex.Queue.addCommand "checkout" [Param "--"] [file]
2011-05-15 06:02:46 +00:00
next $ return True -- no cleanup needed