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
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2013-08-28 20:38:03 +00:00
|
|
|
-}
|
|
|
|
|
|
|
|
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
|
2020-09-15 19:44:37 +00:00
|
|
|
import Git.Types
|
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
|
2020-09-14 20:49:33 +00:00
|
|
|
start o = starting "forget" ai si $ do
|
2020-12-23 19:21:33 +00:00
|
|
|
c <- currentVectorClock
|
2017-08-14 17:55:38 +00:00
|
|
|
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
|
make CommandStart return a StartMessage
The goal is to be able to run CommandStart in the main thread when -J is
used, rather than unncessarily passing it off to a worker thread, which
incurs overhead that is signficant when the CommandStart is going to
quickly decide to stop.
To do that, the message it displays needs to be displayed in the worker
thread, after the CommandStart has run.
Also, the change will mean that CommandStart will no longer necessarily
run with the same Annex state as CommandPerform. While its docs already
said it should avoid modifying Annex state, I audited all the
CommandStart code as part of the conversion. (Note that CommandSeek
already sometimes runs with a different Annex state, and that has not been
a source of any problems, so I am not too worried that this change will
lead to breakage going forward.)
The only modification of Annex state I found was it calling
allowMessages in some Commands that default to noMessages. Dealt with
that by adding a startCustomOutput and a startingUsualMessages.
This lets a command start with noMessages and then select the output it
wants for each CommandStart.
One bit of breakage: onlyActionOn has been removed from commands that used it.
The plan is that, since a StartMessage contains an ActionItem,
when a Key can be extracted from that, the parallel job runner can
run onlyActionOn' automatically. Then commands won't need to worry about
this detail. Future work.
Otherwise, this was a fairly straightforward process of making each
CommandStart compile again. Hopefully other behavior changes were mostly
avoided.
In a few cases, a command had a CommandStart that called a CommandPerform
that then called showStart multiple times. I have collapsed those
down to a single start action. The main command to perhaps suffer from it
is Command.Direct, which used to show a start for each file, and no
longer does.
Another minor behavior change is that some commands used showStart
before, but had an associated file and a Key available, so were changed
to ShowStart with an ActionItemAssociatedFile. That will not change the
normal output or behavior, but --json output will now include the key.
This should not break it for anyone using a real json parser.
2019-06-06 19:42:30 +00:00
|
|
|
perform ts =<< Annex.getState Annex.force
|
2020-09-14 20:49:33 +00:00
|
|
|
where
|
2020-09-15 19:44:37 +00:00
|
|
|
ai = ActionItemOther (Just (fromRef Branch.name))
|
2020-09-14 20:49:33 +00:00
|
|
|
si = SeekInput []
|
2013-08-31 21:38:33 +00:00
|
|
|
|
|
|
|
perform :: Transitions -> Bool -> CommandPerform
|
|
|
|
perform ts True = do
|
start implementing hidden git-annex repositories
This adds a separate journal, which does not currently get committed to
an index, but is planned to be committed to .git/annex/index-private.
Changes that are regarding a UUID that is private will get written to
this journal, and so will not be published into the git-annex branch.
All log writing should have been made to indicate the UUID it's
regarding, though I've not verified this yet.
Currently, no UUIDs are treated as private yet, a way to configure that
is needed.
The implementation is careful to not add any additional IO work when
privateUUIDsKnown is False. It will skip looking at the private journal
at all. So this should be free, or nearly so, unless the feature is
used. When it is used, all branch reads will be about twice as expensive.
It is very lucky -- or very prudent design -- that Annex.Branch.change
and maybeChange are the only ways to change a file on the branch,
and Annex.Branch.set is only internal use. That let Annex.Branch.get
always yield any private information that has been recorded, without
the risk that Annex.Branch.set might be called, with a non-private UUID,
and end up leaking the private information into the git-annex branch.
And, this relies on the way git-annex union merges the git-annex branch.
When reading a file, there can be a public and a private version, and
they are just concacenated together. That will be handled the same as if
there were two diverged git-annex branches that got union merged.
2021-04-20 18:32:41 +00:00
|
|
|
recordTransitions (Branch.change (Branch.RegardingUUID [])) ts
|
2013-08-28 20:38:03 +00:00
|
|
|
-- get branch committed before contining with the transition
|
2020-04-09 17:54:43 +00:00
|
|
|
_ <- 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
|