Abort if earlygetopt fails to detect an option.
Otherwise it could happen that a command is used on the wrong repository,
because abbreviations of --cwd or --repository were ignored.
--- a/mercurial/cmdutil.py Thu Jun 28 15:56:25 2007 +0200
+++ b/mercurial/cmdutil.py Thu Jun 28 16:03:45 2007 +0200
@@ -318,6 +318,15 @@
fullargs = args
cmd, func, args, options, cmdoptions = parse(ui, args)
+ if options["config"]:
+ raise util.Abort(_("Option --config may not be abbreviated!"))
+ if options["cwd"]:
+ raise util.Abort(_("Option --cwd may not be abbreviated!"))
+ if options["repository"]:
+ raise util.Abort(_(
+ "Option -R has to be separated from other options (i.e. not -qR) "
+ "and --repository may only be abbreviated as --repo!"))
+
if options["encoding"]:
util._encoding = options["encoding"]
if options["encodingmode"]:
--- a/tests/test-globalopts Thu Jun 28 15:56:25 2007 +0200
+++ b/tests/test-globalopts Thu Jun 28 16:03:45 2007 +0200
@@ -35,6 +35,14 @@
echo "%% earlygetopt short option without following space"
hg -q -Rb tip
+echo "%% earlygetopt with illegal abbreviations"
+hg --confi "foo.bar=baz"
+hg --cw a tip
+hg --rep a tip
+hg --repositor a tip
+hg -qR a tip
+hg -qRa tip
+
echo %% --cwd
hg --cwd a parents
--- a/tests/test-globalopts.out Thu Jun 28 15:56:25 2007 +0200
+++ b/tests/test-globalopts.out Thu Jun 28 16:03:45 2007 +0200
@@ -48,6 +48,13 @@
%% earlygetopt short option without following space
0:b6c483daf290
+%% earlygetopt with illegal abbreviations
+abort: Option --config may not be abbreviated!
+abort: Option --cwd may not be abbreviated!
+abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo!
+abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo!
+abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo!
+abort: Option -R has to be separated from other options (i.e. not -qR) and --repository may only be abbreviated as --repo!
%% --cwd
changeset: 0:8580ff50825a
tag: tip