diff options
author | Joey Hess <joeyh@joeyh.name> | 2021-04-06 15:14:00 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2021-04-06 15:24:28 -0400 |
commit | d16d739ce28bdb6597552c32e42a1ac972559a95 (patch) | |
tree | 3d0e6d41ddfb8af0c5e4d0ade06d953a297c1384 /Types/DeferredParse.hs | |
parent | 6136006106693331812a8f46d8af9fea713e7aaf (diff) |
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..
Diffstat (limited to 'Types/DeferredParse.hs')
-rw-r--r-- | Types/DeferredParse.hs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Types/DeferredParse.hs b/Types/DeferredParse.hs index 7cfeb148ee..58d40f2fc8 100644 --- a/Types/DeferredParse.hs +++ b/Types/DeferredParse.hs @@ -1,6 +1,6 @@ {- git-annex deferred parse values - - - Copyright 2015 Joey Hess <id@joeyh.name> + - Copyright 2015-2021 Joey Hess <id@joeyh.name> - - Licensed under the GNU AGPL version 3 or higher. -} @@ -12,6 +12,8 @@ module Types.DeferredParse where import Annex import Options.Applicative +import qualified Data.Semigroup as Sem +import Prelude -- Some values cannot be fully parsed without performing an action. -- The action may be expensive, so it's best to call finishParse on such a @@ -36,6 +38,20 @@ instance DeferredParseClass (Maybe (DeferredParse a)) where instance DeferredParseClass [DeferredParse a] where finishParse v = mapM finishParse v --- Use when the Annex action modifies Annex state. -type GlobalSetter = DeferredParse () type GlobalOption = Parser GlobalSetter + +-- Used for global options that can modify Annex state by running +-- an arbitrary action in it, and can also set up AnnexRead. +data GlobalSetter = GlobalSetter + { annexStateSetter :: Annex () + , annexReadSetter :: AnnexRead -> AnnexRead + } + +instance Sem.Semigroup GlobalSetter where + a <> b = GlobalSetter + { annexStateSetter = annexStateSetter a >> annexStateSetter b + , annexReadSetter = annexReadSetter b . annexReadSetter a + } + +instance Monoid GlobalSetter where + mempty = GlobalSetter (return ()) id |