fix perl refugee code

This commit is contained in:
Joey Hess 2010-10-22 20:47:14 -04:00
parent ff38e49eb4
commit f4e2dde8a8
6 changed files with 20 additions and 20 deletions

View file

@ -40,21 +40,21 @@ import qualified TypeInternals as Internals
list :: Annex [Backend] list :: Annex [Backend]
list = do list = do
l <- Annex.backends -- list is cached here l <- Annex.backends -- list is cached here
if (0 < length l) if (not $ null l)
then return l then return l
else do else do
all <- Annex.supportedBackends all <- Annex.supportedBackends
g <- Annex.gitRepo g <- Annex.gitRepo
let l = parseBackendList all $ Git.configGet g "annex.backends" "" let l = parseBackendList all $ Git.configGet g "annex.backends" ""
backendflag <- Annex.flagGet "backend" backendflag <- Annex.flagGet "backend"
let l' = if (0 < length backendflag) let l' = if (not $ null backendflag)
then (lookupBackendName all backendflag):l then (lookupBackendName all backendflag):l
else l else l
Annex.backendsChange $ l' Annex.backendsChange $ l'
return l' return l'
where where
parseBackendList all s = parseBackendList all s =
if (length s == 0) if (null s)
then all then all
else map (lookupBackendName all) $ words s else map (lookupBackendName all) $ words s

View file

@ -62,7 +62,7 @@ checkKeyFile k = do
copyKeyFile :: Key -> FilePath -> Annex (Bool) copyKeyFile :: Key -> FilePath -> Annex (Bool)
copyKeyFile key file = do copyKeyFile key file = do
remotes <- Remotes.withKey key remotes <- Remotes.withKey key
if (0 == length remotes) if (null remotes)
then do then do
showNote "not available" showNote "not available"
showLocations key showLocations key
@ -142,7 +142,7 @@ checkRemoveKey key = do
"Could only verify the existence of " ++ "Could only verify the existence of " ++
(show have) ++ " out of " ++ (show need) ++ (show have) ++ " out of " ++ (show need) ++
" necessary copies" " necessary copies"
if (0 /= length bad) then showTriedRemotes bad else return () if (not $ null bad) then showTriedRemotes bad else return ()
showLocations key showLocations key
hint hint
return False return False
@ -156,9 +156,9 @@ showLocations key = do
uuids <- liftIO $ keyLocations g key uuids <- liftIO $ keyLocations g key
let uuidsf = filter (\v -> v /= u) uuids let uuidsf = filter (\v -> v /= u) uuids
ppuuids <- prettyPrintUUIDs uuidsf ppuuids <- prettyPrintUUIDs uuidsf
if (0 < length uuidsf) if (null uuidsf)
then showLongNote $ "Try making some of these repositories available:\n" ++ ppuuids then showLongNote $ "No other repository is known to contain the file."
else showLongNote $ "No other repository is known to contain the file." else showLongNote $ "Try making some of these repositories available:\n" ++ ppuuids
showTriedRemotes remotes = showTriedRemotes remotes =
showLongNote $ "I was unable to access these remotes: " ++ showLongNote $ "I was unable to access these remotes: " ++

View file

@ -117,9 +117,9 @@ findWanted Description params _ = do
parseCmd :: [String] -> AnnexState -> IO ([Annex ()], [Annex ()]) parseCmd :: [String] -> AnnexState -> IO ([Annex ()], [Annex ()])
parseCmd argv state = do parseCmd argv state = do
(flags, params) <- getopt (flags, params) <- getopt
case (length params) of if (null params)
0 -> error usage then error usage
_ -> case (lookupCmd (params !! 0)) of else case (lookupCmd (params !! 0)) of
[] -> error usage [] -> error usage
[Command _ action want _] -> do [Command _ action want _] -> do
f <- findWanted want (drop 1 params) f <- findWanted want (drop 1 params)
@ -258,7 +258,7 @@ fixCmd file = inBackend file $ \(key, backend) -> do
{- Stores description for the repository. -} {- Stores description for the repository. -}
initCmd :: String -> Annex () initCmd :: String -> Annex ()
initCmd description = do initCmd description = do
if (0 == length description) if (null description)
then error $ then error $
"please specify a description of this repository\n" ++ "please specify a description of this repository\n" ++
usage usage
@ -275,7 +275,7 @@ initCmd description = do
fromKeyCmd :: FilePath -> Annex () fromKeyCmd :: FilePath -> Annex ()
fromKeyCmd file = do fromKeyCmd file = do
keyname <- Annex.flagGet "key" keyname <- Annex.flagGet "key"
if (0 == length keyname) if (null keyname)
then error "please specify the key with --key" then error "please specify the key with --key"
else return () else return ()
backends <- Backend.list backends <- Backend.list

View file

@ -49,11 +49,11 @@ withKey key = do
let cheap = filter (not . Git.repoIsUrl) allremotes let cheap = filter (not . Git.repoIsUrl) allremotes
let expensive = filter Git.repoIsUrl allremotes let expensive = filter Git.repoIsUrl allremotes
doexpensive <- filterM cachedUUID expensive doexpensive <- filterM cachedUUID expensive
if (0 < length doexpensive) if (not $ null doexpensive)
then showNote $ "getting UUIDs for " ++ (list doexpensive) ++ "..." then showNote $ "getting UUIDs for " ++ (list doexpensive) ++ "..."
else return () else return ()
let todo = cheap ++ doexpensive let todo = cheap ++ doexpensive
if (0 < length todo) if (not $ null todo)
then do then do
e <- mapM tryGitConfigRead todo e <- mapM tryGitConfigRead todo
Annex.flagChange "remotesread" $ FlagBool True Annex.flagChange "remotesread" $ FlagBool True
@ -62,7 +62,7 @@ withKey key = do
where where
cachedUUID r = do cachedUUID r = do
u <- getUUID r u <- getUUID r
return $ 0 == length u return $ null u
{- Cost Ordered list of remotes. -} {- Cost Ordered list of remotes. -}
remotesByCost :: Annex [Git.Repo] remotesByCost :: Annex [Git.Repo]
@ -90,7 +90,7 @@ reposByCost l = do
repoCost :: Git.Repo -> Annex Int repoCost :: Git.Repo -> Annex Int
repoCost r = do repoCost r = do
g <- Annex.gitRepo g <- Annex.gitRepo
if ((length $ config g r) > 0) if (not $ null $ config g r)
then return $ read $ config g r then return $ read $ config g r
else if (Git.repoIsUrl r) else if (Git.repoIsUrl r)
then return 200 then return 200

View file

@ -103,7 +103,7 @@ prettyPrintUUIDs uuids = do
return $ unwords $ map (\u -> "\t"++(prettify m u)++"\n") uuids return $ unwords $ map (\u -> "\t"++(prettify m u)++"\n") uuids
where where
prettify m u = prettify m u =
if (0 < (length $ findlog m u)) if (not $ null $ findlog m u)
then u ++ " -- " ++ (findlog m u) then u ++ " -- " ++ (findlog m u)
else u else u
findlog m u = M.findWithDefault "" u m findlog m u = M.findWithDefault "" u m

View file

@ -45,7 +45,7 @@ hGetContentsStrict h = hGetContents h >>= \s -> length s `seq` return s
{- Returns the parent directory of a path. Parent of / is "" -} {- Returns the parent directory of a path. Parent of / is "" -}
parentDir :: String -> String parentDir :: String -> String
parentDir dir = parentDir dir =
if length dirs > 0 if (not $ null dirs)
then slash ++ (join s $ take ((length dirs) - 1) dirs) then slash ++ (join s $ take ((length dirs) - 1) dirs)
else "" else ""
where where
@ -81,7 +81,7 @@ relPathCwdToDir dir = do
-} -}
relPathDirToDir :: FilePath -> FilePath -> FilePath relPathDirToDir :: FilePath -> FilePath -> FilePath
relPathDirToDir from to = relPathDirToDir from to =
if (0 < length path) if (not $ null path)
then addTrailingPathSeparator path then addTrailingPathSeparator path
else "" else ""
where where