syntax tweaks
This commit is contained in:
parent
ecfbc01ff8
commit
694a33e91b
3 changed files with 30 additions and 35 deletions
45
Commands.hs
45
Commands.hs
|
@ -14,7 +14,7 @@ import System.Directory
|
|||
import System.Path
|
||||
import Data.String.Utils
|
||||
import Control.Monad (filterM)
|
||||
import Monad (when)
|
||||
import Monad (when, unless)
|
||||
import List
|
||||
import IO
|
||||
|
||||
|
@ -168,7 +168,7 @@ findWanted FilesMissing params repo = do
|
|||
where
|
||||
missing f = do
|
||||
e <- doesFileExist f
|
||||
if (e) then return False else return True
|
||||
return $ not e
|
||||
findWanted Description params _ = do
|
||||
return $ [unwords params]
|
||||
findWanted FilesToBeCommitted params repo = do
|
||||
|
@ -191,19 +191,18 @@ findWanted _ params _ = return params
|
|||
parseCmd :: [String] -> AnnexState -> IO ([Annex Bool], [Annex Bool])
|
||||
parseCmd argv state = do
|
||||
(flags, params) <- getopt
|
||||
if (null params)
|
||||
then error usage
|
||||
else case (lookupCmd (params !! 0)) of
|
||||
[] -> error usage
|
||||
[Command name action want _] -> do
|
||||
f <- findWanted want (drop 1 params)
|
||||
(TypeInternals.repo state)
|
||||
let actions = map (doSubCmd name action) $
|
||||
filter notstate f
|
||||
let configactions = map (\f -> do
|
||||
f
|
||||
return True) flags
|
||||
return (configactions, actions)
|
||||
when (null params) $ error usage
|
||||
case lookupCmd (params !! 0) of
|
||||
[] -> error usage
|
||||
[Command name action want _] -> do
|
||||
f <- findWanted want (drop 1 params)
|
||||
(TypeInternals.repo state)
|
||||
let actions = map (doSubCmd name action) $
|
||||
filter notstate f
|
||||
let configactions = map (\f -> do
|
||||
f
|
||||
return True) flags
|
||||
return (configactions, actions)
|
||||
where
|
||||
-- never include files from the state directory
|
||||
notstate f = stateLoc /= take (length stateLoc) f
|
||||
|
@ -273,7 +272,7 @@ getPerform :: FilePath -> Key -> Backend -> Annex (Maybe SubCmdCleanup)
|
|||
getPerform file key backend = do
|
||||
ok <- getViaTmp key (Backend.retrieveKeyFile backend key)
|
||||
if (ok)
|
||||
then return $ Just $ return True
|
||||
then return $ Just $ return True -- no cleanup needed
|
||||
else return Nothing
|
||||
|
||||
{- Indicates a file's content is not wanted anymore, and should be removed
|
||||
|
@ -368,11 +367,9 @@ fixCleanup file = do
|
|||
{- Stores description for the repository etc. -}
|
||||
initStart :: String -> Annex (Maybe SubCmdPerform)
|
||||
initStart description = do
|
||||
if (null description)
|
||||
then error $
|
||||
"please specify a description of this repository\n" ++
|
||||
usage
|
||||
else return $ Just $ initPerform description
|
||||
when (null description) $ error $
|
||||
"please specify a description of this repository\n" ++ usage
|
||||
return $ Just $ initPerform description
|
||||
initPerform :: String -> Annex (Maybe SubCmdCleanup)
|
||||
initPerform description = do
|
||||
g <- Annex.gitRepo
|
||||
|
@ -398,9 +395,9 @@ fromKeyStart file = do
|
|||
let key = genKey (backends !! 0) keyname
|
||||
|
||||
inbackend <- Backend.hasKey key
|
||||
if (not inbackend)
|
||||
then error $ "key ("++keyname++") is not present in backend"
|
||||
else return $ Just $ fromKeyPerform file key
|
||||
unless (inbackend) $ error $
|
||||
"key ("++keyname++") is not present in backend"
|
||||
return $ Just $ fromKeyPerform file key
|
||||
fromKeyPerform :: FilePath -> Key -> Annex (Maybe SubCmdCleanup)
|
||||
fromKeyPerform file key = do
|
||||
link <- calcGitLink file key
|
||||
|
|
|
@ -163,6 +163,6 @@ mapLog map log =
|
|||
then Map.insert (uuid log) log map
|
||||
else map
|
||||
where
|
||||
better = case (Map.lookup (uuid log) map) of
|
||||
better = case Map.lookup (uuid log) map of
|
||||
Just l -> (date l <= date log)
|
||||
Nothing -> True
|
||||
|
|
18
Remotes.hs
18
Remotes.hs
|
@ -153,15 +153,13 @@ commandLineRemote = do
|
|||
fromName <- Annex.flagGet "fromrepository"
|
||||
toName <- Annex.flagGet "torepository"
|
||||
let name = if (not $ null fromName) then fromName else toName
|
||||
if (null name)
|
||||
then error "no remote specified"
|
||||
else do
|
||||
g <- Annex.gitRepo
|
||||
let match = filter (\r -> name == Git.repoRemoteName r) $
|
||||
Git.remotes g
|
||||
if (null match)
|
||||
then error $ "there is no git remote named \"" ++ name ++ "\""
|
||||
else return $ match !! 0
|
||||
when (null name) $ error "no remote specified"
|
||||
g <- Annex.gitRepo
|
||||
let match = filter (\r -> name == Git.repoRemoteName r) $
|
||||
Git.remotes g
|
||||
when (null match) $ error $
|
||||
"there is no git remote named \"" ++ name ++ "\""
|
||||
return $ match !! 0
|
||||
|
||||
{- The git configs for the git repo's remotes is not read on startup
|
||||
- because reading it may be expensive. This function tries to read the
|
||||
|
@ -187,7 +185,7 @@ tryGitConfigRead r = do
|
|||
where
|
||||
exchange [] new = []
|
||||
exchange (old:ls) new =
|
||||
if ((Git.repoRemoteName old) == (Git.repoRemoteName new))
|
||||
if (Git.repoRemoteName old == Git.repoRemoteName new)
|
||||
then new:(exchange ls new)
|
||||
else old:(exchange ls new)
|
||||
|
||||
|
|
Loading…
Reference in a new issue