diff options
author | Joey Hess <joey@kitenet.net> | 2011-09-06 17:19:29 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-09-06 17:45:47 -0400 |
commit | 3623d831d193d029a35aac81571d67768b176534 (patch) | |
tree | 23cf930ca5069a7e985ef4f8cc044aec7e9610ee /Trust.hs | |
parent | 6f98fd53914b2490e866a2613e86b93f689034bf (diff) |
refactor
Diffstat (limited to 'Trust.hs')
-rw-r--r-- | Trust.hs | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -9,11 +9,13 @@ module Trust ( TrustLevel(..), trustLog, trustGet, - trustSet + trustSet, + trustPartition ) where import Control.Monad.State import qualified Data.Map as M +import Data.List import Types.TrustLevel import qualified Branch @@ -32,7 +34,7 @@ trustGet level = do return $ M.keys $ M.filter (== level) m {- Read the trustLog into a map, overriding with any - - values from forcetrust -} + - values from forcetrust. The map is cached for speed. -} trustMap :: Annex TrustMap trustMap = do cached <- Annex.getState Annex.trustmap @@ -70,3 +72,9 @@ trustSet uuid level = do where serialize m = unlines $ map showpair $ M.toList m showpair (u, t) = u ++ " " ++ show t + +{- Partitions a list of UUIDs to those matching a TrustLevel and not. -} +trustPartition :: TrustLevel -> [UUID] -> Annex ([UUID], [UUID]) +trustPartition level ls = do + candidates <- trustGet level + return $ partition (`elem` candidates) ls |