[PATCH] bisect: improve option validation message

Brandon McCaig bamccaig at gmail.com
Fri Jun 9 19:39:36 UTC 2017


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 at 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 at gmail.com> <bambams at 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'

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170609/40de0578/attachment.asc>


More information about the Mercurial-devel mailing list