2013-08-28 20:38:03 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
|
|
|
- Copyright 2013 Joey Hess <joey@kitenet.net>
|
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Forget where
|
|
|
|
|
|
|
|
import Common.Annex
|
|
|
|
import Command
|
|
|
|
import qualified Annex.Branch as Branch
|
|
|
|
import Logs.Transitions
|
|
|
|
import qualified Annex
|
2013-08-31 21:38:33 +00:00
|
|
|
import qualified Option
|
2013-08-28 20:38:03 +00:00
|
|
|
|
|
|
|
import Data.Time.Clock.POSIX
|
|
|
|
|
|
|
|
def :: [Command]
|
2013-08-31 21:38:33 +00:00
|
|
|
def = [withOptions forgetOptions $ command "forget" paramNothing seek
|
2013-08-28 20:38:03 +00:00
|
|
|
SectionMaintenance "prune git-annex branch history"]
|
|
|
|
|
2013-08-31 21:38:33 +00:00
|
|
|
forgetOptions :: [Option]
|
|
|
|
forgetOptions = [dropDeadOption]
|
|
|
|
|
|
|
|
dropDeadOption :: Option
|
|
|
|
dropDeadOption = Option.flag [] "drop-dead" "drop references to dead repositories"
|
|
|
|
|
2013-08-28 20:38:03 +00:00
|
|
|
seek :: [CommandSeek]
|
2013-08-31 21:38:33 +00:00
|
|
|
seek = [withFlag dropDeadOption $ \dropdead ->
|
|
|
|
withNothing $ start dropdead]
|
2013-08-28 20:38:03 +00:00
|
|
|
|
2013-08-31 21:38:33 +00:00
|
|
|
start :: Bool -> CommandStart
|
|
|
|
start dropdead = do
|
2013-08-28 20:38:03 +00:00
|
|
|
showStart "forget" "git-annex"
|
|
|
|
now <- liftIO getPOSIXTime
|
2013-08-31 21:38:33 +00:00
|
|
|
let basets = addTransition now ForgetGitHistory noTransitions
|
|
|
|
let ts = if dropdead
|
|
|
|
then addTransition now ForgetDeadRemotes basets
|
|
|
|
else basets
|
|
|
|
next $ perform ts =<< Annex.getState Annex.force
|
|
|
|
|
|
|
|
perform :: Transitions -> Bool -> CommandPerform
|
|
|
|
perform ts True = do
|
2013-08-28 20:38:03 +00:00
|
|
|
recordTransitions Branch.change ts
|
|
|
|
-- get branch committed before contining with the transition
|
|
|
|
Branch.update
|
2013-09-03 20:31:32 +00:00
|
|
|
void $ Branch.performTransitions ts True []
|
2013-08-28 20:38:03 +00:00
|
|
|
next $ return True
|
2013-08-31 21:38:33 +00:00
|
|
|
perform _ False = do
|
2013-08-28 20:38:03 +00:00
|
|
|
showLongNote "To forget git-annex branch history, you must specify --force. This deletes metadata!"
|
|
|
|
stop
|