# HG changeset patch # User Thomas Arendsen Hein # Date 1183039425 -7200 # Node ID 9ac493f12901327814e79a371f8175e5f8bfe376 # Parent 0ecfc3b3f072c534748118a4d1cfc96e05b7f6e1 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. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -318,6 +318,15 @@ def dispatch(ui, args, argv0=None): 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"]: diff --git a/tests/test-globalopts b/tests/test-globalopts --- a/tests/test-globalopts +++ b/tests/test-globalopts @@ -35,6 +35,14 @@ hg --repo c --repository b -R a tip 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 diff --git a/tests/test-globalopts.out b/tests/test-globalopts.out --- a/tests/test-globalopts.out +++ b/tests/test-globalopts.out @@ -48,6 +48,13 @@ summary: a %% 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