# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1290085419 -3600 # Node ID 9c9565643704b8648ea18906cd1d386dd65b674f # Parent caa527346a0fe6d97925c947ce3656bf9d1ef0a7 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. diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- 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)