Patchwork bisect: improve option validation message

login
register
mail settings
Submitter Brandon McCaig
Date June 9, 2017, 4:45 a.m.
Message ID <20170609044505.GB22434@test-chamber-1.castopulence.org>
Download mbox | patch
Permalink /patch/21268/
State Accepted
Headers show

Comments

Brandon McCaig - June 9, 2017, 4:45 a.m.
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@gmail.com>
# Date 1496978716 14400
#      Thu Jun 08 23:25:16 2017 -0400
# Node ID f02156b10abd1d74743a9bea4c905a8620f99331
# Parent  326c0e2c1a1d59e07f4c9d86f81e4419c3d779d8
bisect: improve option validation message


Regards,
Augie Fackler - June 9, 2017, 6:12 p.m.
On Fri, Jun 09, 2017 at 12:45:05AM -0400, Brandon McCaig wrote:
> 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.

Patch looks fine. Could I interest you in adding a quick test of this
functionality to test-bisect.t?

Thanks!

>
> # HG changeset patch
> # User Brandon McCaig <bamccaig@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@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'
>



> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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)