summaryrefslogtreecommitdiff
path: root/Command/Forget.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-08-28 16:38:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-08-28 16:41:13 -0400
commit69bfbd94004d193050e0fe0827f380bdd1ed5644 (patch)
treec0eac16499b9cbc8920c140bd2e1a9bdfd09839b /Command/Forget.hs
parent0ffe5408ae1b396453f080bef2858542317daf23 (diff)
add forget command
Works, more or less. --dead is not implemented, and so far a new branch is made, but keys no longer present anywhere are not scrubbed. git annex sync fails to push the synced/git-annex branch after a forget, because it's not a fast-forward of the existing synced branch. Could be fixed by making git-annex sync use assistant-style sync branches.
Diffstat (limited to 'Command/Forget.hs')
-rw-r--r--Command/Forget.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Command/Forget.hs b/Command/Forget.hs
new file mode 100644
index 000000000..e405a9918
--- /dev/null
+++ b/Command/Forget.hs
@@ -0,0 +1,41 @@
+{- 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
+
+import Data.Time.Clock.POSIX
+
+def :: [Command]
+def = [command "forget" paramNothing seek
+ SectionMaintenance "prune git-annex branch history"]
+
+seek :: [CommandSeek]
+seek = [withNothing start]
+
+start :: CommandStart
+start = do
+ showStart "forget" "git-annex"
+ next $ perform =<< Annex.getState Annex.force
+
+perform :: Bool -> CommandPerform
+perform True = do
+ now <- liftIO getPOSIXTime
+ let ts = addTransition now ForgetGitHistory noTransitions
+ recordTransitions Branch.change ts
+ -- get branch committed before contining with the transition
+ Branch.update
+ void $ Branch.performTransitions ts True
+ next $ return True
+perform False = do
+ showLongNote "To forget git-annex branch history, you must specify --force. This deletes metadata!"
+ stop