fix inverted Ord for TrustLevel (intermediate commit)
This commit removes the Ord and Enum instances, commenting out all code that depends on them, to make sure that all code effected by the inversion fix has been identified. (Assuming no ifdefs involve TrustLevel.) The next commit will fix up all the identified code.
This commit is contained in:
parent
1831cc4a7d
commit
a0e4b9678b
7 changed files with 16 additions and 13 deletions
|
@ -25,10 +25,11 @@ import Data.Ord
|
|||
findExisting :: RemoteName -> Annex (Maybe (UUID, RemoteConfig))
|
||||
findExisting name = do
|
||||
t <- trustMap
|
||||
matches <- sortBy (comparing $ \(u, _c) -> M.lookup u t)
|
||||
headMaybe
|
||||
. reverse
|
||||
-- . sortBy (comparing $ \(u, _c) -> M.lookup u t)
|
||||
. findByName name
|
||||
<$> Logs.Remote.readRemoteLog
|
||||
return $ headMaybe matches
|
||||
|
||||
newConfig :: RemoteName -> RemoteConfig
|
||||
newConfig = M.singleton nameKey
|
||||
|
|
|
@ -300,6 +300,6 @@ willDropMakeItWorse srcuuid destuuid deststartedwithcopy key afile =
|
|||
checktrustlevel = do
|
||||
desttrust <- lookupTrust destuuid
|
||||
srctrust <- lookupTrust srcuuid
|
||||
return (desttrust <= srctrust || desttrust < UnTrusted)
|
||||
return True -- return (desttrust >= srctrust || desttrust > UnTrusted)
|
||||
|
||||
data DropCheck = DropWorse | DropAllowed | DropCheckNumCopies
|
||||
|
|
|
@ -151,14 +151,18 @@ genCfg cfg descs = unlines $ intercalate [""]
|
|||
, com " setting field = value"
|
||||
]
|
||||
|
||||
trust = settings cfg descs cfgTrustMap
|
||||
trust = undefined
|
||||
-- TODO: Down order
|
||||
{- settings cfg descs cfgTrustMap
|
||||
[ com "Repository trust configuration"
|
||||
, com "(Valid trust levels: " ++ trustlevels ++ ")"
|
||||
]
|
||||
(\(t, u) -> line "trust" u $ showTrustLevel t)
|
||||
(\u -> lcom $ line "trust" u $ showTrustLevel def)
|
||||
where
|
||||
trustlevels = unwords $ map showTrustLevel [Trusted .. DeadTrusted]
|
||||
trustlevels = "XXX" -- unwords $ reverse $
|
||||
-- map showTrustLevel [minBound..maxBound]
|
||||
-}
|
||||
|
||||
groups = settings cfg descs cfgGroupMap
|
||||
[ com "Repository groups"
|
||||
|
|
2
Limit.hs
2
Limit.hs
|
@ -180,7 +180,7 @@ limitCopies want = case splitc ':' want of
|
|||
checktrust checker u = checker <$> lookupTrust u
|
||||
checkgroup g u = S.member g <$> lookupGroups u
|
||||
parsetrustspec s
|
||||
| "+" `isSuffixOf` s = (>=) <$> readTrustLevel (beginning s)
|
||||
-- | "+" `isSuffixOf` s = (<=) <$> readTrustLevel (beginning s)
|
||||
| otherwise = (==) <$> readTrustLevel s
|
||||
|
||||
{- Adds a limit to match files that need more copies made. -}
|
||||
|
|
|
@ -72,7 +72,7 @@ trustMapLoad = do
|
|||
map (\r -> (Types.Remote.uuid r, UnTrusted)) exports
|
||||
logged <- trustMapRaw
|
||||
let configured = M.fromList $ mapMaybe configuredtrust l
|
||||
let m = M.unionWith max exportoverrides $
|
||||
let m = --M.unionWith max exportoverrides $
|
||||
M.union overrides $
|
||||
M.union configured logged
|
||||
Annex.changeState $ \s -> s { Annex.trustmap = Just m }
|
||||
|
|
|
@ -31,6 +31,6 @@ showTrustLog DeadTrusted = "X"
|
|||
showTrustLog SemiTrusted = "?"
|
||||
|
||||
prop_parse_show_TrustLog :: Bool
|
||||
prop_parse_show_TrustLog = all check [minBound .. maxBound]
|
||||
prop_parse_show_TrustLog = True -- all check [minBound .. maxBound]
|
||||
where
|
||||
check l = parseTrustLog (showTrustLog l) == l
|
||||
|
|
|
@ -18,10 +18,8 @@ import Data.Default
|
|||
|
||||
import Types.UUID
|
||||
|
||||
-- This order may seem backwards, but we generally want to list dead
|
||||
-- remotes last and trusted ones first.
|
||||
data TrustLevel = Trusted | SemiTrusted | UnTrusted | DeadTrusted
|
||||
deriving (Eq, Enum, Ord, Bounded, Show)
|
||||
data TrustLevel = DeadTrusted | UnTrusted | SemiTrusted | Trusted
|
||||
deriving (Eq, Bounded, Show)
|
||||
|
||||
instance Default TrustLevel where
|
||||
def = SemiTrusted
|
||||
|
@ -42,6 +40,6 @@ showTrustLevel SemiTrusted = "semitrusted"
|
|||
showTrustLevel DeadTrusted = "dead"
|
||||
|
||||
prop_read_show_TrustLevel :: Bool
|
||||
prop_read_show_TrustLevel = all check [minBound .. maxBound]
|
||||
prop_read_show_TrustLevel = True -- all check [minBound .. maxBound]
|
||||
where
|
||||
check l = readTrustLevel (showTrustLevel l) == Just l
|
||||
|
|
Loading…
Reference in a new issue