summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-01-10 13:11:16 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-01-10 13:32:38 -0400
commit07cacbeee95b377e1bf4111e4d4b30190956c585 (patch)
tree17249f177a6ffde3d2f524ee66a9a6b2530bd92e /Logs
parent0d5c4022105a393a4eac76b09940f8b22fa0a56c (diff)
break module dependancy loop
A PITA but worth it to clean up the trust configuration code.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Location.hs14
-rw-r--r--Logs/Trust.hs28
2 files changed, 22 insertions, 20 deletions
diff --git a/Logs/Location.hs b/Logs/Location.hs
index 588962bc5..b6d59b928 100644
--- a/Logs/Location.hs
+++ b/Logs/Location.hs
@@ -16,8 +16,7 @@
module Logs.Location (
LogStatus(..),
logChange,
- readLog,
- keyLocations,
+ loggedLocations,
loggedKeys,
loggedKeysFor,
logFile,
@@ -27,7 +26,6 @@ module Logs.Location (
import Common.Annex
import qualified Annex.Branch
import Logs.Presence
-import Logs.Trust
{- Log a change in the presence of a key's value in a repository. -}
logChange :: Key -> UUID -> LogStatus -> Annex ()
@@ -36,13 +34,9 @@ logChange _ NoUUID _ = return ()
{- Returns a list of repository UUIDs that, according to the log, have
- the value of a key.
- -
- - Dead repositories are skipped.
-}
-keyLocations :: Key -> Annex [UUID]
-keyLocations key = do
- l <- map toUUID <$> (currentLog . logFile) key
- snd <$> trustPartition DeadTrusted l
+loggedLocations :: Key -> Annex [UUID]
+loggedLocations key = map toUUID <$> (currentLog . logFile) key
{- Finds all keys that have location log information.
- (There may be duplicate keys in the list.) -}
@@ -57,7 +51,7 @@ loggedKeysFor u = filterM isthere =<< loggedKeys
{- This should run strictly to avoid the filterM
- building many thunks containing keyLocations data. -}
isthere k = do
- us <- keyLocations k
+ us <- loggedLocations k
let !there = u `elem` us
return there
diff --git a/Logs/Trust.hs b/Logs/Trust.hs
index f6ead87f1..4dd728a8b 100644
--- a/Logs/Trust.hs
+++ b/Logs/Trust.hs
@@ -10,7 +10,6 @@ module Logs.Trust (
trustGet,
trustSet,
trustPartition,
- trustName
) where
import qualified Data.Map as M
@@ -21,6 +20,9 @@ import Types.TrustLevel
import qualified Annex.Branch
import qualified Annex
import Logs.UUIDBased
+import Remote.List
+import Config
+import qualified Types.Remote
{- Filename of trust.log. -}
trustLog :: FilePath
@@ -56,7 +58,7 @@ trustPartition level ls
return $ partition (`elem` candidates) ls
{- Read the trustLog into a map, overriding with any
- - values from forcetrust. The map is cached for speed. -}
+ - values from forcetrust or the git config. The map is cached for speed. -}
trustMap :: Annex TrustMap
trustMap = do
cached <- Annex.getState Annex.trustmap
@@ -66,9 +68,22 @@ trustMap = do
overrides <- Annex.getState Annex.forcetrust
logged <- simpleMap . parseLog (Just . parseTrust) <$>
Annex.Branch.get trustLog
- let m = M.union overrides logged
+ configured <- M.fromList . catMaybes <$>
+ (mapM configuredtrust =<< remoteList)
+ let m = M.union overrides $ M.union configured logged
Annex.changeState $ \s -> s { Annex.trustmap = Just m }
return m
+ where
+ configuredtrust r =
+ maybe Nothing (\l -> Just (Types.Remote.uuid r, l)) <$>
+ (convert <$> getTrustLevel (Types.Remote.repo r))
+ convert :: Maybe String -> Maybe TrustLevel
+ convert Nothing = Nothing
+ convert (Just s)
+ | s == "trusted" = Just Trusted
+ | s == "untrusted" = Just UnTrusted
+ | s == "semitrusted" = Just SemiTrusted
+ | otherwise = Nothing
{- The trust.log used to only list trusted repos, without a field for the
- trust status, which is why this defaults to Trusted. -}
@@ -85,10 +100,3 @@ showTrust Trusted = "1"
showTrust UnTrusted = "0"
showTrust DeadTrusted = "X"
showTrust SemiTrusted = "?"
-
-trustName :: String -> Maybe TrustLevel
-trustName "trusted" = Just Trusted
-trustName "untrusted" = Just UnTrusted
-trustName "deadtrusted" = Just DeadTrusted
-trustName "semitrusted" = Just SemiTrusted
-trustName _ = Nothing