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