diff options
author | Joey Hess <joey@kitenet.net> | 2011-01-26 00:17:38 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-01-26 00:17:38 -0400 |
commit | 6a97b10fcb3e1fa6a230d92a25b42ded587ff743 (patch) | |
tree | b8a6ce70916c397c67788b47de6a389db8753969 /Backend.hs | |
parent | 082b022f9ae56b1446b6607cf7851cd4f1d4f904 (diff) |
rework config storage
Moved away from a map of flags to storing config directly in the AnnexState
structure. Got rid of most accessor functions in Annex.
This allowed supporting multiple --exclude flags.
Diffstat (limited to 'Backend.hs')
-rw-r--r-- | Backend.hs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/Backend.hs b/Backend.hs index 551c041a8..055c5b8ab 100644 --- a/Backend.hs +++ b/Backend.hs @@ -48,20 +48,24 @@ list = do if not $ null l then return l else do + s <- getstandard + d <- Annex.getState Annex.defaultbackend + handle d s + where + parseBackendList l [] = l + parseBackendList bs s = map (lookupBackendName bs) $ words s + handle Nothing s = return s + handle (Just "") s = return s + handle (Just name) s = do bs <- Annex.getState Annex.supportedBackends - g <- Annex.gitRepo - let defaults = parseBackendList bs $ Git.configGet g "annex.backends" "" - backendflag <- Annex.flagGet "backend" - let l' = if not $ null backendflag - then (lookupBackendName bs backendflag):defaults - else defaults - Annex.backendsChange l' + let l' = (lookupBackendName bs name):s + Annex.changeState $ \state -> state { Annex.backends = l' } return l' - where - parseBackendList bs s = - if null s - then bs - else map (lookupBackendName bs) $ words s + getstandard = do + bs <- Annex.getState Annex.supportedBackends + g <- Annex.gitRepo + return $ parseBackendList bs $ + Git.configGet g "annex.backends" "" {- Looks up a backend in a list. May fail if unknown. -} lookupBackendName :: [Backend Annex] -> String -> Backend Annex |