From 3623d831d193d029a35aac81571d67768b176534 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 6 Sep 2011 17:19:29 -0400 Subject: refactor --- Trust.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Trust.hs') diff --git a/Trust.hs b/Trust.hs index 365186da2..232eea6a5 100644 --- a/Trust.hs +++ b/Trust.hs @@ -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 -- cgit v1.2.3