2013-08-28 20:38:03 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2013 Joey Hess <id@joeyh.name>
|
2013-08-28 20:38:03 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Command.Forget where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import qualified Annex.Branch as Branch
|
|
|
|
import Logs.Transitions
|
|
|
|
import qualified Annex
|
2017-08-14 17:55:38 +00:00
|
|
|
import Annex.VectorClock
|
2013-08-28 20:38:03 +00:00
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2015-07-11 04:42:32 +00:00
|
|
|
cmd = command "forget" SectionMaintenance
|
|
|
|
"prune git-annex branch history"
|
|
|
|
paramNothing (seek <$$> optParser)
|
|
|
|
|
|
|
|
data ForgetOptions = ForgetOptions
|
|
|
|
{ dropDead :: Bool
|
|
|
|
}
|
|
|
|
|
|
|
|
optParser :: CmdParamsDesc -> Parser ForgetOptions
|
|
|
|
optParser _ = ForgetOptions
|
|
|
|
<$> switch
|
|
|
|
( long "drop-dead"
|
|
|
|
<> help "drop references to dead repositories"
|
|
|
|
)
|
|
|
|
|
|
|
|
seek :: ForgetOptions -> CommandSeek
|
|
|
|
seek = commandAction . start
|
|
|
|
|
|
|
|
start :: ForgetOptions -> CommandStart
|
|
|
|
start o = do
|
2017-11-28 18:40:26 +00:00
|
|
|
showStart' "forget" (Just "git-annex")
|
2017-08-14 17:55:38 +00:00
|
|
|
c <- liftIO currentVectorClock
|
|
|
|
let basets = addTransition c ForgetGitHistory noTransitions
|
2015-07-11 04:42:32 +00:00
|
|
|
let ts = if dropDead o
|
2017-08-14 17:55:38 +00:00
|
|
|
then addTransition c ForgetDeadRemotes basets
|
2013-08-31 21:38:33 +00:00
|
|
|
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
|