use new getConfig

This commit is contained in:
Joey Hess 2012-03-22 00:23:15 -04:00
parent 4eb5112681
commit f1398b5583
8 changed files with 16 additions and 21 deletions

View file

@ -33,7 +33,6 @@ import Common.Annex
import Logs.Location import Logs.Location
import Annex.UUID import Annex.UUID
import qualified Git import qualified Git
import qualified Git.Config
import qualified Annex import qualified Annex
import qualified Annex.Queue import qualified Annex.Queue
import qualified Annex.Branch import qualified Annex.Branch
@ -308,7 +307,7 @@ saveState oneshot = do
( Annex.Branch.commit "update" , Annex.Branch.stage) ( Annex.Branch.commit "update" , Annex.Branch.stage)
where where
alwayscommit = fromMaybe True . Git.configTrue alwayscommit = fromMaybe True . Git.configTrue
<$> fromRepo (Git.Config.get "annex.alwayscommit" "") <$> getConfig "annex.alwayscommit" ""
{- Downloads content from any of a list of urls. -} {- Downloads content from any of a list of urls. -}
downloadUrl :: [Url.URLString] -> FilePath -> Annex Bool downloadUrl :: [Url.URLString] -> FilePath -> Annex Bool

View file

@ -14,7 +14,7 @@ module Annex.Queue (
import Common.Annex import Common.Annex
import Annex hiding (new) import Annex hiding (new)
import qualified Git.Queue import qualified Git.Queue
import qualified Git.Config import Config
{- Adds a git command to the queue. -} {- Adds a git command to the queue. -}
add :: String -> [CommandParam] -> [FilePath] -> Annex () add :: String -> [CommandParam] -> [FilePath] -> Annex ()
@ -43,11 +43,11 @@ get = maybe new return =<< getState repoqueue
new :: Annex Git.Queue.Queue new :: Annex Git.Queue.Queue
new = do new = do
q <- Git.Queue.new <$> fromRepo queuesize q <- Git.Queue.new <$> queuesize
store q store q
return q return q
where where
queuesize r = readish =<< Git.Config.getMaybe "annex.queuesize" r queuesize = readish <$> getConfig "annex.queuesize" ""
store :: Git.Queue.Queue -> Annex () store :: Git.Queue.Queue -> Annex ()
store q = changeState $ \s -> s { repoqueue = Just q } store q = changeState $ \s -> s { repoqueue = Just q }

View file

@ -15,7 +15,7 @@ import qualified Data.Map as M
import Common.Annex import Common.Annex
import Annex.LockPool import Annex.LockPool
import qualified Git import qualified Git
import qualified Git.Config import Config
import qualified Build.SysConfig as SysConfig import qualified Build.SysConfig as SysConfig
{- Generates parameters to ssh to a given host (or user@host) on a given {- Generates parameters to ssh to a given host (or user@host) on a given
@ -47,7 +47,7 @@ sshInfo (host, port) = ifM caching
where where
caching = fromMaybe SysConfig.sshconnectioncaching caching = fromMaybe SysConfig.sshconnectioncaching
. Git.configTrue . Git.configTrue
<$> fromRepo (Git.Config.get "annex.sshcaching" "") <$> getConfig "annex.sshcaching" ""
cacheParams :: FilePath -> [CommandParam] cacheParams :: FilePath -> [CommandParam]
cacheParams socketfile = cacheParams socketfile =

View file

@ -47,7 +47,7 @@ getUUID = getRepoUUID =<< gitRepo
{- Looks up a repo's UUID, caching it in .git/config if it's not already. -} {- Looks up a repo's UUID, caching it in .git/config if it's not already. -}
getRepoUUID :: Git.Repo -> Annex UUID getRepoUUID :: Git.Repo -> Annex UUID
getRepoUUID r = do getRepoUUID r = do
c <- fromRepo cached c <- toUUID <$> getConfig cachekey ""
let u = getUncachedUUID r let u = getUncachedUUID r
if c /= u && u /= NoUUID if c /= u && u /= NoUUID
@ -56,7 +56,6 @@ getRepoUUID r = do
return u return u
else return c else return c
where where
cached = toUUID . Git.Config.get cachekey ""
updatecache u = do updatecache u = do
g <- gitRepo g <- gitRepo
when (g /= r) $ storeUUID cachekey u when (g /= r) $ storeUUID cachekey u

View file

@ -8,7 +8,6 @@
module Annex.Version where module Annex.Version where
import Common.Annex import Common.Annex
import qualified Git.Config
import Config import Config
type Version = String type Version = String
@ -26,7 +25,7 @@ versionField :: String
versionField = "annex.version" versionField = "annex.version"
getVersion :: Annex (Maybe Version) getVersion :: Annex (Maybe Version)
getVersion = handle <$> fromRepo (Git.Config.get versionField "") getVersion = handle <$> getConfig versionField ""
where where
handle [] = Nothing handle [] = Nothing
handle v = Just v handle v = Just v

View file

@ -18,7 +18,7 @@ module Backend (
import System.Posix.Files import System.Posix.Files
import Common.Annex import Common.Annex
import qualified Git.Config import Config
import qualified Annex import qualified Annex
import Annex.CheckAttr import Annex.CheckAttr
import Types.Key import Types.Key
@ -46,7 +46,7 @@ orderedList = do
l' <- (lookupBackendName name :) <$> standard l' <- (lookupBackendName name :) <$> standard
Annex.changeState $ \s -> s { Annex.backends = l' } Annex.changeState $ \s -> s { Annex.backends = l' }
return l' return l'
standard = fromRepo $ parseBackendList . Git.Config.get "annex.backends" "" standard = parseBackendList <$> getConfig "annex.backends" ""
parseBackendList [] = list parseBackendList [] = list
parseBackendList s = map lookupBackendName $ words s parseBackendList s = map lookupBackendName $ words s

View file

@ -23,13 +23,13 @@ import Annex.Content
import Utility.FileMode import Utility.FileMode
import Utility.TempFile import Utility.TempFile
import Logs.Location import Logs.Location
import Config
import qualified Annex import qualified Annex
import qualified Git import qualified Git
import qualified Git.Command import qualified Git.Command
import qualified Git.Ref import qualified Git.Ref
import qualified Git.LsFiles as LsFiles import qualified Git.LsFiles as LsFiles
import qualified Git.LsTree as LsTree import qualified Git.LsTree as LsTree
import qualified Git.Config
import qualified Backend import qualified Backend
import qualified Remote import qualified Remote
import qualified Annex.Branch import qualified Annex.Branch
@ -189,10 +189,10 @@ exclude smaller larger = S.toList $ remove larger $ S.fromList smaller
-} -}
bloomCapacity :: Annex Int bloomCapacity :: Annex Int
bloomCapacity = fromMaybe 500000 . readish bloomCapacity = fromMaybe 500000 . readish
<$> fromRepo (Git.Config.get "annex.bloomcapacity" "") <$> getConfig "annex.bloomcapacity" ""
bloomAccuracy :: Annex Int bloomAccuracy :: Annex Int
bloomAccuracy = fromMaybe 1000 . readish bloomAccuracy = fromMaybe 1000 . readish
<$> fromRepo (Git.Config.get "annex.bloomaccuracy" "") <$> getConfig "annex.bloomaccuracy" ""
bloomBitsHashes :: Annex (Int, Int) bloomBitsHashes :: Annex (Int, Int)
bloomBitsHashes = do bloomBitsHashes = do
capacity <- bloomCapacity capacity <- bloomCapacity

View file

@ -32,9 +32,8 @@ getConfig key def = fromRepo $ Git.Config.get key def
{- Looks up a per-remote config setting in git config. {- Looks up a per-remote config setting in git config.
- Failing that, tries looking for a global config option. -} - Failing that, tries looking for a global config option. -}
getRemoteConfig :: Git.Repo -> ConfigKey -> String -> Annex String getRemoteConfig :: Git.Repo -> ConfigKey -> String -> Annex String
getRemoteConfig r key def = do getRemoteConfig r key def =
def' <- getConfig key def getConfig (remoteConfig r key) =<< getConfig key def
fromRepo $ Git.Config.get (remoteConfig r key) def'
{- A per-remote config setting in git config. -} {- A per-remote config setting in git config. -}
remoteConfig :: Git.Repo -> ConfigKey -> String remoteConfig :: Git.Repo -> ConfigKey -> String
@ -85,9 +84,8 @@ getNumCopies v = perhaps (use v) =<< Annex.getState Annex.forcenumcopies
where where
use (Just n) = return n use (Just n) = return n
use Nothing = perhaps (return 1) =<< use Nothing = perhaps (return 1) =<<
readish <$> fromRepo (Git.Config.get config "1") readish <$> getConfig "annex.numcopies" "1"
perhaps fallback = maybe fallback (return . id) perhaps fallback = maybe fallback (return . id)
config = "annex.numcopies"
{- Gets the trust level set for a remote in git config. -} {- Gets the trust level set for a remote in git config. -}
getTrustLevel :: Git.Repo -> Annex (Maybe String) getTrustLevel :: Git.Repo -> Annex (Maybe String)