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 Common.Annex
|
|
|
|
import Command
|
|
|
|
import qualified Annex.Branch as Branch
|
|
|
|
import Logs.Transitions
|
|
|
|
import qualified Annex
|
|
|
|
|
|
|
|
import Data.Time.Clock.POSIX
|
|
|
|
|
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
|
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
|
2015-07-11 04:42:32 +00:00
|
|
|
let ts = if dropDead o
|
2013-08-31 21:38:33 +00:00
|
|
|
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
|