Mercurial > hgsubversion
diff hgsubversion/svncommands.py @ 755:9c9565643704
svn metacommand: improved argument checking
We now fail gracefully in case of a missing or invalid argument to
'update', and in case of an unknown subcommand.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Thu, 18 Nov 2010 14:03:39 +0100 |
parents | caa527346a0f |
children | bf1c27a89c76 |
line wrap: on
line diff
--- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -302,8 +302,15 @@ def update(ui, args, repo, clean=False, """update to a specified Subversion revision number """ - assert len(args) == 1 - rev = int(args[0]) + try: + rev = int(args[0]) + except IndexError: + raise error.CommandError('svn', + "no revision number specified for 'update'") + except ValueError: + raise error.Abort("'%s' is not a valid Subversion revision number" + % args[0]) + meta = repo.svnmeta() answers = [] @@ -457,6 +464,9 @@ def svn(ui, repo, subcommand, *args, **o candidates.append(c) if len(candidates) == 1: subcommand = candidates[0] + elif not candidates: + raise error.CommandError('svn', + "unknown subcommand '%s'" % subcommand) else: raise error.AmbiguousCommand(subcommand, candidates)