[PATCH] bisect: improve option validation message

Brandon McCaig bamccaig at gmail.com
Fri Jun 9 04:45:05 UTC 2017


Today I was trying to figure out when something had happened in a repo. I
decided to try bisecting history with a command to determine when
something had happened. I was confused by the command options and
when I tried to mark good and bad changesets as a starting point
I was confused by the output:

> $ hg bisect -g -r 0
> abort: incompatible arguments

I couldn't figure out what was wrong at first, and after
reviewing several times and asking in IRC it finally occurred to
me that bisect's -r option is not --rev. It's --reset. It
occurred to me that the error message was far too vague to make
this clear. I opted to try submitting a patch that might make
this more clear for future users.

That patch follows.

# HG changeset patch
# User Brandon McCaig <bamccaig at gmail.com>
# Date 1496978716 14400
#      Thu Jun 08 23:25:16 2017 -0400
# Node ID f02156b10abd1d74743a9bea4c905a8620f99331
# Parent  326c0e2c1a1d59e07f4c9d86f81e4419c3d779d8
bisect: improve option validation message

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -768,8 +768,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'))
 
     if reset:
         hbisect.resetstate(repo)

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://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170609/3a33cc74/attachment.sig>


More information about the Mercurial-devel mailing list