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 = do
l <- Annex.backends -- list is cached here
if (0 < length l)
if (not $ null l)
then return l
else do
all <- Annex.supportedBackends
g <- Annex.gitRepo
let l = parseBackendList all $ Git.configGet g "annex.backends" ""
backendflag <- Annex.flagGet "backend"
let l' = if (0 < length backendflag)
let l' = if (not $ null backendflag)
then (lookupBackendName all backendflag):l
else l
Annex.backendsChange $ l'
return l'
where
parseBackendList all s =
if (length s == 0)
if (null s)
then all
else map (lookupBackendName all) $ words s

View file

@ -62,7 +62,7 @@ checkKeyFile k = do
copyKeyFile :: Key -> FilePath -> Annex (Bool)
copyKeyFile key file = do
remotes <- Remotes.withKey key
if (0 == length remotes)
if (null remotes)
then do
showNote "not available"
showLocations key
@ -142,7 +142,7 @@ checkRemoveKey key = do
"Could only verify the existence of " ++
(show have) ++ " out of " ++ (show need) ++
" necessary copies"
if (0 /= length bad) then showTriedRemotes bad else return ()
if (not $ null bad) then showTriedRemotes bad else return ()
showLocations key
hint
return False
@ -156,9 +156,9 @@ showLocations key = do
uuids <- liftIO $ keyLocations g key
let uuidsf = filter (\v -> v /= u) uuids
ppuuids <- prettyPrintUUIDs uuidsf
if (0 < length uuidsf)
then showLongNote $ "Try making some of these repositories available:\n" ++ ppuuids
else showLongNote $ "No other repository is known to contain the file."
if (null uuidsf)
then showLongNote $ "No other repository is known to contain the file."
else showLongNote $ "Try making some of these repositories available:\n" ++ ppuuids
showTriedRemotes 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 argv state = do
(flags, params) <- getopt
case (length params) of
0 -> error usage
_ -> case (lookupCmd (params !! 0)) of
if (null params)
then error usage
else case (lookupCmd (params !! 0)) of
[] -> error usage
[Command _ action want _] -> do
f <- findWanted want (drop 1 params)
@ -258,7 +258,7 @@ fixCmd file = inBackend file $ \(key, backend) -> do
{- Stores description for the repository. -}
initCmd :: String -> Annex ()
initCmd description = do
if (0 == length description)
if (null description)
then error $
"please specify a description of this repository\n" ++
usage
@ -275,7 +275,7 @@ initCmd description = do
fromKeyCmd :: FilePath -> Annex ()
fromKeyCmd file = do
keyname <- Annex.flagGet "key"
if (0 == length keyname)
if (null keyname)
then error "please specify the key with --key"
else return ()
backends <- Backend.list

View file

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

View file

@ -103,7 +103,7 @@ prettyPrintUUIDs uuids = do
return $ unwords $ map (\u -> "\t"++(prettify m u)++"\n") uuids
where
prettify m u =
if (0 < (length $ findlog m u))
if (not $ null $ findlog m u)
then u ++ " -- " ++ (findlog m u)
else u
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 "" -}
parentDir :: String -> String
parentDir dir =
if length dirs > 0
if (not $ null dirs)
then slash ++ (join s $ take ((length dirs) - 1) dirs)
else ""
where
@ -81,7 +81,7 @@ relPathCwdToDir dir = do
-}
relPathDirToDir :: FilePath -> FilePath -> FilePath
relPathDirToDir from to =
if (0 < length path)
if (not $ null path)
then addTrailingPathSeparator path
else ""
where