diff options
author | Joey Hess <joey@kitenet.net> | 2011-12-15 18:11:42 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-12-15 18:19:36 -0400 |
commit | 95d2391f58ae240e7100f0d5488dd7246f71f3bb (patch) | |
tree | f33f21904ae7be4d40b70bab1e2a68fd4eef5526 /Logs | |
parent | b7e0d39abbc9a09c21c6f0103ad6c9f4547f81fe (diff) |
more partial function removal
Left a few Prelude.head's in where it was checked not null and too hard to
remove, etc.
Diffstat (limited to 'Logs')
-rw-r--r-- | Logs/Location.hs | 4 | ||||
-rw-r--r-- | Logs/Remote.hs | 5 | ||||
-rw-r--r-- | Logs/Trust.hs | 14 | ||||
-rw-r--r-- | Logs/UUID.hs | 4 |
4 files changed, 12 insertions, 15 deletions
diff --git a/Logs/Location.hs b/Logs/Location.hs index 27b4d709e..588962bc5 100644 --- a/Logs/Location.hs +++ b/Logs/Location.hs @@ -68,7 +68,7 @@ logFile key = hashDirLower key ++ keyFile key ++ ".log" {- Converts a log filename into a key. -} logFileKey :: FilePath -> Maybe Key logFileKey file - | end == ".log" = fileKey beginning + | ext == ".log" = fileKey base | otherwise = Nothing where - (beginning, end) = splitAt (length file - 4) file + (base, ext) = splitAt (length file - 4) file diff --git a/Logs/Remote.hs b/Logs/Remote.hs index 8d15f3151..d9b41d8c4 100644 --- a/Logs/Remote.hs +++ b/Logs/Remote.hs @@ -73,14 +73,13 @@ configUnEscape = unescape | c == '&' = entity rest | otherwise = c : unescape rest entity s = if ok - then chr (read num) : unescape rest + then chr (Prelude.read num) : unescape rest else '&' : unescape s where num = takeWhile isNumber s r = drop (length num) s rest = drop 1 r - ok = not (null num) && - not (null r) && head r == ';' + ok = not (null num) && take 1 r == ";" {- for quickcheck -} prop_idempotent_configEscape :: String -> Bool diff --git a/Logs/Trust.hs b/Logs/Trust.hs index 196666a84..5d769bd24 100644 --- a/Logs/Trust.hs +++ b/Logs/Trust.hs @@ -54,18 +54,16 @@ trustMap = do Just m -> return m Nothing -> do overrides <- M.fromList <$> Annex.getState Annex.forcetrust - m <- (M.union overrides . simpleMap . parseLog parseTrust) <$> + m <- (M.union overrides . simpleMap . parseLog (Just . parseTrust)) <$> Annex.Branch.get trustLog Annex.changeState $ \s -> s { Annex.trustmap = Just m } return m -parseTrust :: String -> Maybe TrustLevel -parseTrust s - | length w > 0 = Just $ parse $ head w - -- back-compat; the trust.log used to only list trusted repos - | otherwise = Just Trusted +{- The trust.log used to only list trusted repos, without a field for the + - trust status, which is why this defaults to Trusted. -} +parseTrust :: String -> TrustLevel +parseTrust s = maybe Trusted parse $ headMaybe $ words s where - w = words s parse "1" = Trusted parse "0" = UnTrusted parse "X" = DeadTrusted @@ -82,6 +80,6 @@ trustSet :: UUID -> TrustLevel -> Annex () trustSet uuid@(UUID _) level = do ts <- liftIO getPOSIXTime Annex.Branch.change trustLog $ - showLog showTrust . changeLog ts uuid level . parseLog parseTrust + showLog showTrust . changeLog ts uuid level . parseLog (Just . parseTrust) Annex.changeState $ \s -> s { Annex.trustmap = Nothing } trustSet NoUUID _ = error "unknown UUID; cannot modify trust level" diff --git a/Logs/UUID.hs b/Logs/UUID.hs index b325c78b6..18cbee61e 100644 --- a/Logs/UUID.hs +++ b/Logs/UUID.hs @@ -57,9 +57,9 @@ fixBadUUID = M.fromList . map fixup . M.toList kuuid = fromUUID k isbad = not (isuuid kuuid) && isuuid lastword ws = words $ value v - lastword = last ws + lastword = Prelude.last ws fixeduuid = toUUID lastword - fixedvalue = unwords $ kuuid: init ws + fixedvalue = unwords $ kuuid: Prelude.init ws -- For the fixed line to take precidence, it should be -- slightly newer, but only slightly. newertime (LogEntry (Date d) _) = d + minimumPOSIXTimeSlice |