From dd463a3100f21d72c35ca1af5b0f63f6296cf322 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 18 Sep 2011 20:11:39 -0400 Subject: [PATCH] rework annex-ignore handling Only one place need to filter the list of remotes for ignored remotes: keyPossibilities. Make the full list available to everything else. This allows getting rid of the special case handing for --from and --to to make ignored remotes not be ignored with those options. --- Annex.hs | 4 ++-- Config.hs | 14 +++----------- Remote.hs | 6 ++---- Remote/Bup.hs | 3 ++- Remote/Directory.hs | 3 ++- Remote/Git.hs | 3 ++- Remote/Hook.hs | 3 ++- Remote/Rsync.hs | 3 ++- Remote/S3real.hs | 3 ++- Remote/Web.hs | 3 ++- Types/Remote.hs | 4 +++- 11 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Annex.hs b/Annex.hs index ad65e05ddf..1517a34708 100644 --- a/Annex.hs +++ b/Annex.hs @@ -26,7 +26,7 @@ import Control.Applicative hiding (empty) import qualified Git import Git.Queue import Types.Backend -import Types.Remote +import qualified Types.Remote import Types.Crypto import Types.BranchState import Types.TrustLevel @@ -48,7 +48,7 @@ newtype Annex a = Annex { runAnnex :: StateT AnnexState IO a } data AnnexState = AnnexState { repo :: Git.Repo , backends :: [Backend Annex] - , remotes :: [Remote Annex] + , remotes :: [Types.Remote.Remote Annex] , repoqueue :: Queue , output :: OutputType , force :: Bool diff --git a/Config.hs b/Config.hs index b4f4c0b922..fe847fce1c 100644 --- a/Config.hs +++ b/Config.hs @@ -82,18 +82,10 @@ prop_cost_sane = False `notElem` {- Checks if a repo should be ignored, based either on annex-ignore - setting, or on command-line options. Allows command-line to override - annex-ignore. -} -remoteNotIgnored :: Git.Repo -> Annex Bool -remoteNotIgnored r = do +repoNotIgnored :: Git.Repo -> Annex Bool +repoNotIgnored r = do ignored <- getConfig r "ignore" "false" - to <- match Annex.toremote - from <- match Annex.fromremote - if to || from - then return True - else return $ not $ Git.configTrue ignored - where - match a = do - n <- Annex.getState a - return $ n == Git.repoRemoteName r + return $ not $ Git.configTrue ignored {- If a value is specified, it is used; otherwise the default is looked up - in git config. forcenumcopies overrides everything. -} diff --git a/Remote.hs b/Remote.hs index 429f9058b6..0ce01872ac 100644 --- a/Remote.hs +++ b/Remote.hs @@ -16,7 +16,6 @@ module Remote ( hasKeyCheap, remoteTypes, - genList, byName, prettyPrintUUIDs, remotesWithUUID, @@ -29,7 +28,7 @@ module Remote ( forceTrust ) where -import Control.Monad (filterM) +import Control.Monad.State (filterM) import Data.List import qualified Data.Map as M import Data.String.Utils @@ -83,7 +82,6 @@ genList = do where process m t = enumerate t >>= - filterM remoteNotIgnored >>= mapM (gen m t) gen m t r = do u <- getUUID r @@ -184,7 +182,7 @@ keyPossibilities' withtrusted key = do let validtrusteduuids = validuuids `intersect` trusted -- remotes that match uuids that have the key - allremotes <- genList + allremotes <- filterM (repoNotIgnored . repo) =<< genList let validremotes = remotesWithUUID allremotes validuuids return (sort validremotes, validtrusteduuids) diff --git a/Remote/Bup.hs b/Remote/Bup.hs index ebb4b10a5b..29c7a0419f 100644 --- a/Remote/Bup.hs +++ b/Remote/Bup.hs @@ -66,7 +66,8 @@ gen r u c = do removeKey = remove, hasKey = checkPresent r bupr', hasKeyCheap = bupLocal buprepo, - config = c + config = c, + repo = r } bupSetup :: UUID -> RemoteConfig -> Annex RemoteConfig diff --git a/Remote/Directory.hs b/Remote/Directory.hs index 7ddb60462f..b183042ef6 100644 --- a/Remote/Directory.hs +++ b/Remote/Directory.hs @@ -57,7 +57,8 @@ gen r u c = do removeKey = remove dir, hasKey = checkPresent dir, hasKeyCheap = True, - config = Nothing + config = Nothing, + repo = r } directorySetup :: UUID -> RemoteConfig -> Annex RemoteConfig diff --git a/Remote/Git.hs b/Remote/Git.hs index fadd48a036..9789a06252 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -71,7 +71,8 @@ gen r u _ = do removeKey = dropKey r', hasKey = inAnnex r', hasKeyCheap = cheap, - config = Nothing + config = Nothing, + repo = r' } {- Tries to read the config for a specified remote, updates state, and diff --git a/Remote/Hook.hs b/Remote/Hook.hs index 54b9806ffc..aaeb702c7b 100644 --- a/Remote/Hook.hs +++ b/Remote/Hook.hs @@ -58,7 +58,8 @@ gen r u c = do removeKey = remove hooktype, hasKey = checkPresent r hooktype, hasKeyCheap = False, - config = Nothing + config = Nothing, + repo = r } hookSetup :: UUID -> RemoteConfig -> Annex RemoteConfig diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index 3707966ad6..9d2d7ddcf7 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -66,7 +66,8 @@ gen r u c = do removeKey = remove o, hasKey = checkPresent r o, hasKeyCheap = False, - config = Nothing + config = Nothing, + repo = r } genRsyncOpts :: Git.Repo -> Annex RsyncOpts diff --git a/Remote/S3real.hs b/Remote/S3real.hs index 456a77f0e4..77b6b6ca40 100644 --- a/Remote/S3real.hs +++ b/Remote/S3real.hs @@ -67,7 +67,8 @@ gen' r u c cst = removeKey = remove this, hasKey = checkPresent this, hasKeyCheap = False, - config = c + config = c, + repo = r } s3Setup :: UUID -> RemoteConfig -> Annex RemoteConfig diff --git a/Remote/Web.hs b/Remote/Web.hs index 3695bb1ab3..8fb29ec403 100644 --- a/Remote/Web.hs +++ b/Remote/Web.hs @@ -58,7 +58,8 @@ gen r _ _ = removeKey = dropKey, hasKey = checkKey, hasKeyCheap = False, - config = Nothing + config = Nothing, + repo = r } {- The urls for a key are stored in remote/web/hash/key.log diff --git a/Types/Remote.hs b/Types/Remote.hs index 8d9622c519..49f16bfdd7 100644 --- a/Types/Remote.hs +++ b/Types/Remote.hs @@ -51,7 +51,9 @@ data Remote a = Remote { -- operation. hasKeyCheap :: Bool, -- a Remote can have a persistent configuration store - config :: Maybe RemoteConfig + config :: Maybe RemoteConfig, + -- git configuration for the remote + repo :: Git.Repo } instance Show (Remote a) where