Patchwork bisect: improve option validation message

login
register
mail settings
Submitter Brandon McCaig
Date June 9, 2017, 7:39 p.m.
Message ID <20170609193936.GA18212@test-chamber-1.castopulence.org>
Download mbox | patch
Permalink /patch/21291/
State Accepted
Headers show

Comments

Brandon McCaig - June 9, 2017, 7:39 p.m.
On Fri, Jun 09, 2017 at 02:12:58PM -0400, Augie Fackler wrote:
> On Fri, Jun 09, 2017 at 12:45:05AM -0400, Brandon McCaig wrote:
> Patch looks fine. Could I interest you in adding a quick test
> of this functionality to test-bisect.t?
>
> Thanks!

How about this?

# HG changeset patch
# User Brandon McCaig <bamccaig@gmail.com>
# Date 1496978716 14400
#      Thu Jun 08 23:25:16 2017 -0400
# Node ID 6720094c6deb90192b46569c43e0707a85bc8cca
# Parent  1c658391b22fb4d98ccfb60c0e57315b55634117
bisect: improve option validation message


Regards,
Augie Fackler - June 9, 2017, 7:50 p.m.
> On Jun 9, 2017, at 15:39, Brandon McCaig <bamccaig@gmail.com> wrote:
> 
> On Fri, Jun 09, 2017 at 02:12:58PM -0400, Augie Fackler wrote:
>> On Fri, Jun 09, 2017 at 12:45:05AM -0400, Brandon McCaig wrote:
>> Patch looks fine. Could I interest you in adding a quick test
>> of this functionality to test-bisect.t?
>> 
>> Thanks!
> 
> How about this?

It's a pareto improvement over what we've got, so I've queued it. I'd encourage some painting of the bike shed on the particular wording/formatting of the error message to be a bit more in line with our other messages as a follow-up.

Thanks!

> 
> # HG changeset patch
> # User Brandon McCaig <bamccaig@gmail.com>
> # Date 1496978716 14400
> #      Thu Jun 08 23:25:16 2017 -0400
> # Node ID 6720094c6deb90192b46569c43e0707a85bc8cca
> # Parent  1c658391b22fb4d98ccfb60c0e57315b55634117
> bisect: improve option validation message
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -892,8 +892,11 @@
>             bad = True
>         else:
>             reset = True
> -    elif extra or good + bad + skip + reset + extend + bool(command) > 1:
> +    elif extra:
>         raise error.Abort(_('incompatible arguments'))
> +    elif good + bad + skip + reset + extend + bool(command) > 1:
> +        raise error.Abort(_('-g|--good, -b|--bad, -s|--skip, -r|--reset, '
> +                            '-e|--extend, and -c|--command are exclusive'))
> 
>     cmdutil.checkunfinished(repo)
> 
> diff --git a/tests/test-bisect.t b/tests/test-bisect.t
> --- a/tests/test-bisect.t
> +++ b/tests/test-bisect.t
> @@ -604,3 +604,51 @@
>   date:        Thu Jan 01 00:00:26 1970 +0000
>   summary:     msg 26
> 
> +Test the validation message when exclusive options are used:
> +
> +  $ hg bisect -r
> +  $ hg bisect -b -c false
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -b -e
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -b -g
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -b -r
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -b -s
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -c false -e
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -c false -g
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -c false -r
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -c false -s
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -e -g
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -e -r
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -e -s
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -g -r
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -g -s
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> +  $ hg bisect -r -s
> +  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
> +  [255]
> 
> Regards,
> 
> 
> -- 
> Brandon McCaig <bamccaig@gmail.com> <bambams@castopulence.org>
> Castopulence Software <https://www.castopulence.org/>
> Blog <http://www.bambams.ca/>
> perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
> q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
> tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'
>

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -892,8 +892,11 @@ 
             bad = True
         else:
             reset = True
-    elif extra or good + bad + skip + reset + extend + bool(command) > 1:
+    elif extra:
         raise error.Abort(_('incompatible arguments'))
+    elif good + bad + skip + reset + extend + bool(command) > 1:
+        raise error.Abort(_('-g|--good, -b|--bad, -s|--skip, -r|--reset, '
+                            '-e|--extend, and -c|--command are exclusive'))
 
     cmdutil.checkunfinished(repo)
 
diff --git a/tests/test-bisect.t b/tests/test-bisect.t
--- a/tests/test-bisect.t
+++ b/tests/test-bisect.t
@@ -604,3 +604,51 @@ 
   date:        Thu Jan 01 00:00:26 1970 +0000
   summary:     msg 26
   
+Test the validation message when exclusive options are used:
+
+  $ hg bisect -r
+  $ hg bisect -b -c false
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -b -e
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -b -g
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -b -r
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -b -s
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -c false -e
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -c false -g
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -c false -r
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -c false -s
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -e -g
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -e -r
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -e -s
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -g -r
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -g -s
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]
+  $ hg bisect -r -s
+  abort: -g|--good, -b|--bad, -s|--skip, -r|--reset, -e|--extend, and -c|--command are exclusive
+  [255]