1{- git-annex repository differences 2 - 3 - Copyright 2015 Joey Hess <id@joeyh.name> 4 - 5 - Licensed under the GNU AGPL version 3 or higher. 6 -} 7 8module Annex.Difference ( 9 module Types.Difference, 10 setDifferences, 11) where 12 13import Annex.Common 14import Types.Difference 15import Logs.Difference 16import Config 17import Annex.UUID 18import Logs.UUID 19import Annex.Version 20import qualified Annex 21 22import qualified Data.Map as M 23 24-- Differences are only allowed to be tweaked when initializing a 25-- repository for the first time, and then only if there is not another 26-- known uuid. If the repository was cloned from elsewhere, it inherits 27-- the existing settings. 28-- 29-- Must be called before setVersion, so it can check if this is the first 30-- time the repository is being initialized. 31setDifferences :: Annex () 32setDifferences = do 33 u <- getUUID 34 otherds <- allDifferences <$> recordedDifferences 35 ds <- mappend otherds . annexDifferences <$> Annex.getGitConfig 36 when (ds /= mempty) $ do 37 ds' <- ifM (isJust <$> getVersion) 38 ( do 39 oldds <- recordedDifferencesFor u 40 when (ds /= oldds) $ 41 warning "Cannot change tunable parameters in already initialized repository." 42 return oldds 43 , if otherds == mempty 44 then ifM (any (/= u) . M.keys <$> uuidDescMap) 45 ( do 46 warning "Cannot change tunable parameters in a clone of an existing repository." 47 return mempty 48 , return ds 49 ) 50 else if otherds /= ds 51 then do 52 warning "The specified tunable parameters differ from values being used in other clones of this repository." 53 return otherds 54 else return ds 55 ) 56 forM_ (listDifferences ds') $ \d -> 57 setConfig (differenceConfigKey d) (differenceConfigVal d) 58 recordDifferences ds' u 59