implement fastDebug

Most of the changes here involve global option parsing: GlobalSetter
changed so it can both run an Annex action to set state, but can also
change the AnnexRead value, which is immutable once the Annex monad is
running.

That allowed a debugselector value to be added to AnnexRead, seeded
from the git config. The --debugfilter option's GlobalSetter then updates
the AnnexRead.

This improved GlobalSetter can later be used to move more stuff to
AnnexRead. Things that don't involve a git config will be easier to
move, and probably a *lot* of things can be moved eventually.

fastDebug, while implemented, is not used anywhere yet. But it should be
fast..
This commit is contained in:
Joey Hess 2021-04-06 15:14:00 -04:00
parent 6136006106
commit d16d739ce2
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
12 changed files with 194 additions and 84 deletions

View file

@ -20,46 +20,47 @@ import Types.GitConfig
import Git.Types (ConfigKey(..))
import Git.Config
import Utility.FileSystemEncoding
import Annex.Debug
-- Global options accepted by both git-annex and git-annex-shell sub-commands.
commonGlobalOptions :: [GlobalOption]
commonGlobalOptions =
[ globalFlag (setforce True)
[ globalFlag (setAnnexState $ setforce True)
( long "force"
<> help "allow actions that may lose annexed data"
<> hidden
)
, globalFlag (setfast True)
, globalFlag (setAnnexState $ setfast True)
( long "fast" <> short 'F'
<> help "avoid slow operations"
<> hidden
)
, globalFlag (Annex.setOutput QuietOutput)
, globalFlag (setAnnexState $ Annex.setOutput QuietOutput)
( long "quiet" <> short 'q'
<> help "avoid verbose output"
<> hidden
)
, globalFlag (Annex.setOutput NormalOutput)
, globalFlag (setAnnexState $ Annex.setOutput NormalOutput)
( long "verbose" <> short 'v'
<> help "allow verbose output (default)"
<> hidden
)
, globalFlag (setdebug True)
, globalFlag (setAnnexState $ setdebug True)
( long "debug" <> short 'd'
<> help "show debug messages"
<> hidden
)
, globalFlag (setdebug False)
, globalFlag (setAnnexState $ setdebug False)
( long "no-debug"
<> help "don't show debug messages"
<> hidden
)
, globalSetter setdebugfilter $ strOption
, globalOption setdebugfilter $ strOption
( long "debugfilter" <> metavar "NAME[,NAME..]"
<> help "show debug messages coming from a module"
<> hidden
)
, globalSetter setforcebackend $ strOption
, globalOption setforcebackend $ strOption
( long "backend" <> short 'b' <> metavar paramName
<> help "specify key-value backend to use"
<> hidden
@ -67,13 +68,26 @@ commonGlobalOptions =
]
where
setforce v = Annex.changeState $ \s -> s { Annex.force = v }
setfast v = Annex.changeState $ \s -> s { Annex.fast = v }
setforcebackend v = Annex.changeState $ \s -> s { Annex.forcebackend = Just v }
setforcebackend v = setAnnexState $
Annex.changeState $ \s -> s { Annex.forcebackend = Just v }
-- Overriding this way, rather than just setting annexDebug
-- makes the config be passed on to any git-annex child processes.
setdebug v = Annex.addGitConfigOverride $
decodeBS' $ debugconfig <> "=" <> boolConfig' v
setdebugfilter v = Annex.addGitConfigOverride $
decodeBS' (debugfilterconfig <> "=") ++ v
setdebugfilter v = mconcat
[ setAnnexRead $ \rd -> rd
{ Annex.debugselector = parseDebugSelector v
}
-- Also set in git config so it will be passed on to any
-- git-annex child processes.
, setAnnexState $ Annex.addGitConfigOverride $
decodeBS' (debugfilterconfig <> "=") ++ v
]
(ConfigKey debugconfig) = annexConfig "debug"
(ConfigKey debugfilterconfig) = annexConfig "debugfilter"