summaryrefslogtreecommitdiff
path: root/Logs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-10-03 17:04:52 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-10-03 17:04:52 -0400
commita08863d8b8613b067766d0dca33c1f0c651d498d (patch)
treee7c9a5a6007428a5ecf1393a5df71f2a574c2c76 /Logs
parent3bb9a92952f0da499315c897e3489fc02188618c (diff)
vicfg: New command, allows editing (or simply viewing) most of the repository configuration settings stored in the git-annex branch.
Incomplete; I need to finish parsing and saving. This will also be used for editing transfer control expresssions. Removed the group display from the status output, I didn't really like that format, and vicfg can be used to see as well as edit rempository group membership.
Diffstat (limited to 'Logs')
-rw-r--r--Logs/Trust.hs40
1 files changed, 19 insertions, 21 deletions
diff --git a/Logs/Trust.hs b/Logs/Trust.hs
index a929832a0..ce7615ba5 100644
--- a/Logs/Trust.hs
+++ b/Logs/Trust.hs
@@ -10,8 +10,8 @@ module Logs.Trust (
trustGet,
trustSet,
trustPartition,
- readTrust,
lookupTrust,
+ trustMapRaw,
) where
import qualified Data.Map as M
@@ -42,7 +42,9 @@ trustSet :: UUID -> TrustLevel -> Annex ()
trustSet uuid@(UUID _) level = do
ts <- liftIO getPOSIXTime
Annex.Branch.change trustLog $
- showLog showTrust . changeLog ts uuid level . parseLog (Just . parseTrust)
+ showLog showTrustLog .
+ changeLog ts uuid level .
+ parseLog (Just . parseTrustLog)
Annex.changeState $ \s -> s { Annex.trustmap = Nothing }
trustSet NoUUID _ = error "unknown UUID; cannot modify trust level"
@@ -72,38 +74,34 @@ trustMap = do
Just m -> return m
Nothing -> do
overrides <- Annex.getState Annex.forcetrust
- logged <- simpleMap . parseLog (Just . parseTrust) <$>
- Annex.Branch.get trustLog
- configured <- M.fromList . catMaybes <$>
- (mapM configuredtrust =<< remoteList)
+ logged <- trustMapRaw
+ 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)) <$>
- maybe Nothing readTrust <$>
- getTrustLevel (Types.Remote.repo r)
+ maybe Nothing readTrustLevel
+ <$> getTrustLevel (Types.Remote.repo r)
-readTrust :: String -> Maybe TrustLevel
-readTrust "trusted" = Just Trusted
-readTrust "untrusted" = Just UnTrusted
-readTrust "semitrusted" = Just SemiTrusted
-readTrust "dead" = Just DeadTrusted
-readTrust _ = Nothing
+trustMapRaw :: Annex TrustMap
+trustMapRaw = simpleMap . parseLog (Just . parseTrustLog)
+ <$> Annex.Branch.get trustLog
{- The trust.log used to only list trusted repos, without a field for the
- trust status, which is why this defaults to Trusted. -}
-parseTrust :: String -> TrustLevel
-parseTrust s = maybe Trusted parse $ headMaybe $ words s
+parseTrustLog :: String -> TrustLevel
+parseTrustLog s = maybe Trusted parse $ headMaybe $ words s
where
parse "1" = Trusted
parse "0" = UnTrusted
parse "X" = DeadTrusted
parse _ = SemiTrusted
-showTrust :: TrustLevel -> String
-showTrust Trusted = "1"
-showTrust UnTrusted = "0"
-showTrust DeadTrusted = "X"
-showTrust SemiTrusted = "?"
+showTrustLog :: TrustLevel -> String
+showTrustLog Trusted = "1"
+showTrustLog UnTrusted = "0"
+showTrustLog DeadTrusted = "X"
+showTrustLog SemiTrusted = "?"