avoid version check before running version and upgrade commands

There are two types of commands; those that access the repository and those
that don't. Sorted.
This commit is contained in:
Joey Hess 2011-03-19 18:58:49 -04:00
parent 54c39d09ba
commit 140a351fc5
33 changed files with 46 additions and 37 deletions

View file

@ -45,7 +45,9 @@ parseCmd argv header cmds options = do
[] -> error $ "unknown command" ++ usagemsg [] -> error $ "unknown command" ++ usagemsg
[command] -> do [command] -> do
_ <- sequence flags _ <- sequence flags
prepCmd command (drop 1 params) when (cmdusesrepo command) $
checkVersion
prepCommand command (drop 1 params)
_ -> error "internal error: multiple matching commands" _ -> error "internal error: multiple matching commands"
where where
getopt = case getOpt Permute options argv of getopt = case getOpt Permute options argv of
@ -93,7 +95,6 @@ tryRun' _ errnum [] = do
startup :: Annex Bool startup :: Annex Bool
startup = do startup = do
prepUUID prepUUID
checkVersion
return True return True
{- Cleanup actions. -} {- Cleanup actions. -}

View file

@ -61,13 +61,20 @@ data Command = Command {
cmdname :: String, cmdname :: String,
cmdparams :: String, cmdparams :: String,
cmdseek :: [CommandSeek], cmdseek :: [CommandSeek],
cmddesc :: String cmddesc :: String,
cmdusesrepo :: Bool
} }
repoCommand :: String -> String -> [CommandSeek] -> String -> Command
repoCommand n p s d = Command n p s d True
standaloneCommand :: String -> String -> [CommandSeek] -> String -> Command
standaloneCommand n p s d = Command n p s d False
{- Prepares a list of actions to run to perform a command, based on {- Prepares a list of actions to run to perform a command, based on
- the parameters passed to it. -} - the parameters passed to it. -}
prepCmd :: Command -> [String] -> Annex [Annex Bool] prepCommand :: Command -> [String] -> Annex [Annex Bool]
prepCmd Command { cmdseek = seek } params = do prepCommand Command { cmdseek = seek } params = do
lists <- mapM (\s -> s params) seek lists <- mapM (\s -> s params) seek
return $ map doCommand $ concat lists return $ map doCommand $ concat lists

View file

@ -21,7 +21,7 @@ import Utility
import Touch import Touch
command :: [Command] command :: [Command]
command = [Command "add" paramPath seek "add files to annex"] command = [repoCommand "add" paramPath seek "add files to annex"]
{- Add acts on both files not checked into git yet, and unlocked files. -} {- Add acts on both files not checked into git yet, and unlocked files. -}
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -14,7 +14,7 @@ import Command
import UUID import UUID
command :: [Command] command :: [Command]
command = [Command "configlist" paramNothing seek command = [standaloneCommand "configlist" paramNothing seek
"outputs relevant git configuration"] "outputs relevant git configuration"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -11,7 +11,7 @@ import Command
import qualified Command.Move import qualified Command.Move
command :: [Command] command :: [Command]
command = [Command "copy" paramPath seek command = [repoCommand "copy" paramPath seek
"copy content of files to/from another repository"] "copy content of files to/from another repository"]
-- A copy is just a move that does not delete the source file. -- A copy is just a move that does not delete the source file.

View file

@ -16,7 +16,7 @@ import Messages
import qualified Command.Init import qualified Command.Init
command :: [Command] command :: [Command]
command = [Command "describe" (paramPair paramRemote paramDesc) seek command = [repoCommand "describe" (paramPair paramRemote paramDesc) seek
"change description of a repository"] "change description of a repository"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -18,7 +18,7 @@ import Messages
import Utility import Utility
command :: [Command] command :: [Command]
command = [Command "drop" paramPath seek command = [repoCommand "drop" paramPath seek
"indicate content of files not currently wanted"] "indicate content of files not currently wanted"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -15,7 +15,7 @@ import Content
import Messages import Messages
command :: [Command] command :: [Command]
command = [Command "dropkey" (paramRepeating paramKey) seek command = [repoCommand "dropkey" (paramRepeating paramKey) seek
"drops annexed content for specified keys"] "drops annexed content for specified keys"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -23,7 +23,7 @@ import Backend
import Key import Key
command :: [Command] command :: [Command]
command = [Command "dropunused" (paramRepeating paramNumber) seek command = [repoCommand "dropunused" (paramRepeating paramNumber) seek
"drop unused file content"] "drop unused file content"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -14,7 +14,7 @@ import Command
import Content import Content
command :: [Command] command :: [Command]
command = [Command "find" (paramOptional $ paramRepeating paramPath) seek command = [repoCommand "find" (paramOptional $ paramRepeating paramPath) seek
"lists available files"] "lists available files"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -18,7 +18,7 @@ import Content
import Messages import Messages
command :: [Command] command :: [Command]
command = [Command "fix" paramPath seek command = [repoCommand "fix" paramPath seek
"fix up symlinks to point to annexed content"] "fix up symlinks to point to annexed content"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -21,7 +21,7 @@ import Messages
import Key import Key
command :: [Command] command :: [Command]
command = [Command "fromkey" paramPath seek command = [repoCommand "fromkey" paramPath seek
"adds a file using a specific key"] "adds a file using a specific key"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -20,7 +20,7 @@ import Content
import LocationLog import LocationLog
command :: [Command] command :: [Command]
command = [Command "fsck" (paramOptional $ paramRepeating paramPath) seek command = [repoCommand "fsck" (paramOptional $ paramRepeating paramPath) seek
"check for problems"] "check for problems"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -14,7 +14,7 @@ import Content
import Messages import Messages
command :: [Command] command :: [Command]
command = [Command "get" paramPath seek command = [repoCommand "get" paramPath seek
"make content of annexed files available"] "make content of annexed files available"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -14,7 +14,7 @@ import Command
import Content import Content
command :: [Command] command :: [Command]
command = [Command "inannex" (paramRepeating paramKey) seek command = [repoCommand "inannex" (paramRepeating paramKey) seek
"checks if keys are present in the annex"] "checks if keys are present in the annex"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -23,7 +23,7 @@ import Types
import Utility import Utility
command :: [Command] command :: [Command]
command = [Command "init" paramDesc seek command = [repoCommand "init" paramDesc seek
"initialize git-annex with repository description"] "initialize git-annex with repository description"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -17,7 +17,7 @@ import qualified GitRepo as Git
import Utility import Utility
command :: [Command] command :: [Command]
command = [Command "lock" paramPath seek "undo unlock command"] command = [repoCommand "lock" paramPath seek "undo unlock command"]
seek :: [CommandSeek] seek :: [CommandSeek]
seek = [withFilesUnlocked start] seek = [withFilesUnlocked start]

View file

@ -29,7 +29,7 @@ import qualified Dot
data Link = Link Git.Repo Git.Repo data Link = Link Git.Repo Git.Repo
command :: [Command] command :: [Command]
command = [Command "map" paramNothing seek "generate map of repositories"] command = [repoCommand "map" paramNothing seek "generate map of repositories"]
seek :: [CommandSeek] seek :: [CommandSeek]
seek = [withNothing start] seek = [withNothing start]

View file

@ -21,7 +21,7 @@ import Messages
import qualified Command.Add import qualified Command.Add
command :: [Command] command :: [Command]
command = [Command "migrate" paramPath seek "switch data to different backend"] command = [repoCommand "migrate" paramPath seek "switch data to different backend"]
seek :: [CommandSeek] seek :: [CommandSeek]
seek = [withBackendFilesInGit start] seek = [withBackendFilesInGit start]

View file

@ -22,7 +22,7 @@ import Messages
import Utility import Utility
command :: [Command] command :: [Command]
command = [Command "move" paramPath seek command = [repoCommand "move" paramPath seek
"move content of files to/from another repository"] "move content of files to/from another repository"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -17,7 +17,7 @@ import qualified Command.Fix
import Utility import Utility
command :: [Command] command :: [Command]
command = [Command "pre-commit" paramPath seek "run by git pre-commit hook"] command = [repoCommand "pre-commit" paramPath seek "run by git pre-commit hook"]
{- The pre-commit hook needs to fix symlinks to all files being committed. {- The pre-commit hook needs to fix symlinks to all files being committed.
- And, it needs to inject unlocked files into the annex. -} - And, it needs to inject unlocked files into the annex. -}

View file

@ -17,7 +17,7 @@ import Content
import RsyncFile import RsyncFile
command :: [Command] command :: [Command]
command = [Command "recvkey" paramKey seek command = [repoCommand "recvkey" paramKey seek
"runs rsync in server mode to receive content"] "runs rsync in server mode to receive content"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -15,7 +15,7 @@ import Trust
import Messages import Messages
command :: [Command] command :: [Command]
command = [Command "semitrust" (paramRepeating paramRemote) seek command = [repoCommand "semitrust" (paramRepeating paramRemote) seek
"return repository to default trust level"] "return repository to default trust level"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -18,7 +18,7 @@ import Content
import RsyncFile import RsyncFile
command :: [Command] command :: [Command]
command = [Command "sendkey" paramKey seek command = [repoCommand "sendkey" paramKey seek
"runs rsync in server mode to send content"] "runs rsync in server mode to send content"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -16,7 +16,7 @@ import Content
import Messages import Messages
command :: [Command] command :: [Command]
command = [Command "setkey" (paramRepeating paramKey) seek command = [repoCommand "setkey" (paramRepeating paramKey) seek
"sets annexed content for a key using a temp file"] "sets annexed content for a key using a temp file"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -15,7 +15,7 @@ import UUID
import Messages import Messages
command :: [Command] command :: [Command]
command = [Command "trust" (paramRepeating paramRemote) seek command = [repoCommand "trust" (paramRepeating paramRemote) seek
"trust a repository"] "trust a repository"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -22,7 +22,7 @@ import qualified GitRepo as Git
import Messages import Messages
command :: [Command] command :: [Command]
command = [Command "unannex" paramPath seek "undo accidential add command"] command = [repoCommand "unannex" paramPath seek "undo accidential add command"]
seek :: [CommandSeek] seek :: [CommandSeek]
seek = [withFilesInGit start] seek = [withFilesInGit start]

View file

@ -21,7 +21,7 @@ import qualified Command.Unannex
import qualified Command.Init import qualified Command.Init
command :: [Command] command :: [Command]
command = [Command "uninit" paramPath seek command = [repoCommand "uninit" paramPath seek
"de-initialize git-annex and clean out repository"] "de-initialize git-annex and clean out repository"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -22,8 +22,8 @@ import CopyFile
command :: [Command] command :: [Command]
command = command =
[ Command "unlock" paramPath seek "unlock files for modification" [ repoCommand "unlock" paramPath seek "unlock files for modification"
, Command "edit" paramPath seek "same as unlock" , repoCommand "edit" paramPath seek "same as unlock"
] ]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -15,7 +15,7 @@ import Trust
import Messages import Messages
command :: [Command] command :: [Command]
command = [Command "untrust" (paramRepeating paramRemote) seek command = [repoCommand "untrust" (paramRepeating paramRemote) seek
"do not trust a repository"] "do not trust a repository"]
seek :: [CommandSeek] seek :: [CommandSeek]

View file

@ -25,7 +25,8 @@ import qualified GitRepo as Git
import qualified Backend import qualified Backend
command :: [Command] command :: [Command]
command = [Command "unused" paramNothing seek "look for unused file content"] command = [repoCommand "unused" paramNothing seek
"look for unused file content"]
seek :: [CommandSeek] seek :: [CommandSeek]
seek = [withNothing start] seek = [withNothing start]

View file

@ -15,7 +15,7 @@ import qualified SysConfig
import Version import Version
command :: [Command] command :: [Command]
command = [Command "version" paramNothing seek "show versions"] command = [standaloneCommand "version" paramNothing seek "show version info"]
seek :: [CommandSeek] seek :: [CommandSeek]
seek = [withNothing start] seek = [withNothing start]

View file

@ -17,7 +17,7 @@ import UUID
import Types import Types
command :: [Command] command :: [Command]
command = [Command "whereis" (paramOptional $ paramRepeating paramPath) seek command = [repoCommand "whereis" (paramOptional $ paramRepeating paramPath) seek
"lists repositories that have file content"] "lists repositories that have file content"]
seek :: [CommandSeek] seek :: [CommandSeek]