From 16187361258dae573f8aba012be25622fcc599af Mon Sep 17 00:00:00 2001 From: Dan Villiom Podlaski Christiansen Date: Thu, 18 Nov 2010 14:03:39 +0100 Subject: [PATCH] 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. --- hgsubversion/svncommands.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py index 11c442a111..b62a8f85fd 100644 --- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -302,8 +302,15 @@ def update(ui, args, repo, clean=False, **opts): """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, **opts): 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)