From f1398b558316a936690a8f3b01493f498d15b659 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Mar 2012 00:23:15 -0400 Subject: use new getConfig --- Annex/Content.hs | 3 +-- Annex/Queue.hs | 6 +++--- Annex/Ssh.hs | 4 ++-- Annex/UUID.hs | 3 +-- Annex/Version.hs | 3 +-- Backend.hs | 4 ++-- Command/Unused.hs | 6 +++--- Config.hs | 8 +++----- 8 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Annex/Content.hs b/Annex/Content.hs index e0cfa7227..7bb94aec2 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -33,7 +33,6 @@ import Common.Annex import Logs.Location import Annex.UUID import qualified Git -import qualified Git.Config import qualified Annex import qualified Annex.Queue import qualified Annex.Branch @@ -308,7 +307,7 @@ saveState oneshot = do ( Annex.Branch.commit "update" , Annex.Branch.stage) where alwayscommit = fromMaybe True . Git.configTrue - <$> fromRepo (Git.Config.get "annex.alwayscommit" "") + <$> getConfig "annex.alwayscommit" "" {- Downloads content from any of a list of urls. -} downloadUrl :: [Url.URLString] -> FilePath -> Annex Bool diff --git a/Annex/Queue.hs b/Annex/Queue.hs index df6ba12a2..f49a22069 100644 --- a/Annex/Queue.hs +++ b/Annex/Queue.hs @@ -14,7 +14,7 @@ module Annex.Queue ( import Common.Annex import Annex hiding (new) import qualified Git.Queue -import qualified Git.Config +import Config {- Adds a git command to the queue. -} add :: String -> [CommandParam] -> [FilePath] -> Annex () @@ -43,11 +43,11 @@ get = maybe new return =<< getState repoqueue new :: Annex Git.Queue.Queue new = do - q <- Git.Queue.new <$> fromRepo queuesize + q <- Git.Queue.new <$> queuesize store q return q where - queuesize r = readish =<< Git.Config.getMaybe "annex.queuesize" r + queuesize = readish <$> getConfig "annex.queuesize" "" store :: Git.Queue.Queue -> Annex () store q = changeState $ \s -> s { repoqueue = Just q } diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs index 79cfbe908..e6cd6a926 100644 --- a/Annex/Ssh.hs +++ b/Annex/Ssh.hs @@ -15,7 +15,7 @@ import qualified Data.Map as M import Common.Annex import Annex.LockPool import qualified Git -import qualified Git.Config +import Config import qualified Build.SysConfig as SysConfig {- Generates parameters to ssh to a given host (or user@host) on a given @@ -47,7 +47,7 @@ sshInfo (host, port) = ifM caching where caching = fromMaybe SysConfig.sshconnectioncaching . Git.configTrue - <$> fromRepo (Git.Config.get "annex.sshcaching" "") + <$> getConfig "annex.sshcaching" "" cacheParams :: FilePath -> [CommandParam] cacheParams socketfile = diff --git a/Annex/UUID.hs b/Annex/UUID.hs index 0ab2e7e52..e8306de90 100644 --- a/Annex/UUID.hs +++ b/Annex/UUID.hs @@ -47,7 +47,7 @@ getUUID = getRepoUUID =<< gitRepo {- Looks up a repo's UUID, caching it in .git/config if it's not already. -} getRepoUUID :: Git.Repo -> Annex UUID getRepoUUID r = do - c <- fromRepo cached + c <- toUUID <$> getConfig cachekey "" let u = getUncachedUUID r if c /= u && u /= NoUUID @@ -56,7 +56,6 @@ getRepoUUID r = do return u else return c where - cached = toUUID . Git.Config.get cachekey "" updatecache u = do g <- gitRepo when (g /= r) $ storeUUID cachekey u diff --git a/Annex/Version.hs b/Annex/Version.hs index 917859eae..cf5d22484 100644 --- a/Annex/Version.hs +++ b/Annex/Version.hs @@ -8,7 +8,6 @@ module Annex.Version where import Common.Annex -import qualified Git.Config import Config type Version = String @@ -26,7 +25,7 @@ versionField :: String versionField = "annex.version" getVersion :: Annex (Maybe Version) -getVersion = handle <$> fromRepo (Git.Config.get versionField "") +getVersion = handle <$> getConfig versionField "" where handle [] = Nothing handle v = Just v diff --git a/Backend.hs b/Backend.hs index 6810c3a44..19562205c 100644 --- a/Backend.hs +++ b/Backend.hs @@ -18,7 +18,7 @@ module Backend ( import System.Posix.Files import Common.Annex -import qualified Git.Config +import Config import qualified Annex import Annex.CheckAttr import Types.Key @@ -46,7 +46,7 @@ orderedList = do l' <- (lookupBackendName name :) <$> standard Annex.changeState $ \s -> s { Annex.backends = l' } return l' - standard = fromRepo $ parseBackendList . Git.Config.get "annex.backends" "" + standard = parseBackendList <$> getConfig "annex.backends" "" parseBackendList [] = list parseBackendList s = map lookupBackendName $ words s diff --git a/Command/Unused.hs b/Command/Unused.hs index 246929f71..bc721635b 100644 --- a/Command/Unused.hs +++ b/Command/Unused.hs @@ -23,13 +23,13 @@ import Annex.Content import Utility.FileMode import Utility.TempFile import Logs.Location +import Config import qualified Annex import qualified Git import qualified Git.Command import qualified Git.Ref import qualified Git.LsFiles as LsFiles import qualified Git.LsTree as LsTree -import qualified Git.Config import qualified Backend import qualified Remote import qualified Annex.Branch @@ -189,10 +189,10 @@ exclude smaller larger = S.toList $ remove larger $ S.fromList smaller -} bloomCapacity :: Annex Int bloomCapacity = fromMaybe 500000 . readish - <$> fromRepo (Git.Config.get "annex.bloomcapacity" "") + <$> getConfig "annex.bloomcapacity" "" bloomAccuracy :: Annex Int bloomAccuracy = fromMaybe 1000 . readish - <$> fromRepo (Git.Config.get "annex.bloomaccuracy" "") + <$> getConfig "annex.bloomaccuracy" "" bloomBitsHashes :: Annex (Int, Int) bloomBitsHashes = do capacity <- bloomCapacity diff --git a/Config.hs b/Config.hs index 39fe3333b..f20298485 100644 --- a/Config.hs +++ b/Config.hs @@ -32,9 +32,8 @@ getConfig key def = fromRepo $ Git.Config.get key def {- Looks up a per-remote config setting in git config. - Failing that, tries looking for a global config option. -} getRemoteConfig :: Git.Repo -> ConfigKey -> String -> Annex String -getRemoteConfig r key def = do - def' <- getConfig key def - fromRepo $ Git.Config.get (remoteConfig r key) def' +getRemoteConfig r key def = + getConfig (remoteConfig r key) =<< getConfig key def {- A per-remote config setting in git config. -} remoteConfig :: Git.Repo -> ConfigKey -> String @@ -85,9 +84,8 @@ getNumCopies v = perhaps (use v) =<< Annex.getState Annex.forcenumcopies where use (Just n) = return n use Nothing = perhaps (return 1) =<< - readish <$> fromRepo (Git.Config.get config "1") + readish <$> getConfig "annex.numcopies" "1" perhaps fallback = maybe fallback (return . id) - config = "annex.numcopies" {- Gets the trust level set for a remote in git config. -} getTrustLevel :: Git.Repo -> Annex (Maybe String) -- cgit v1.2.3