Mercurial > hg
changeset 4734:9ac493f12901
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.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Thu, 28 Jun 2007 16:03:45 +0200 |
parents | 0ecfc3b3f072 |
children | 8d4fac0a9df7 |
files | mercurial/cmdutil.py tests/test-globalopts tests/test-globalopts.out |
diffstat | 3 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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