From f77979b8b5ef1dc59b45c03ba6febfacdf904491 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 3 Oct 2011 15:41:25 -0400 Subject: improved git-annex branch changing All changes to files in the branch are now made via pure functions that transform the old file into the new. This will allow adding locking to prevent read/write races. It also makes the code nicer, and purer. I noticed a behavior change, really a sort of bug fix. Before, 'git annex untrust foo --trust bar' would change both trust levels permanantly, now the --trust doesn't get stored. --- Trust.hs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Trust.hs') diff --git a/Trust.hs b/Trust.hs index 232eea6a5..0c8836c85 100644 --- a/Trust.hs +++ b/Trust.hs @@ -64,11 +64,9 @@ trustSet :: UUID -> TrustLevel -> Annex () trustSet uuid level = do when (null uuid) $ error "unknown UUID; cannot modify trust level" - m <- trustMap - when (M.lookup uuid m /= Just level) $ do - let m' = M.insert uuid level m - Branch.change trustLog (serialize m') - Annex.changeState $ \s -> s { Annex.trustmap = Just m' } + Branch.change trustLog $ + serialize . M.insert uuid level . M.fromList . trustMapParse + Annex.changeState $ \s -> s { Annex.trustmap = Nothing } where serialize m = unlines $ map showpair $ M.toList m showpair (u, t) = u ++ " " ++ show t -- cgit v1.2.3