[PATCH] bisect: improve option validation message

Brandon McCaig bamccaig at gmail.com
Wed Jun 14 01:51:46 EDT 2017

On Sun, Jun 11, 2017 at 02:14:28PM +0900, Yuya Nishihara wrote:
> > I’m about to wander away from my laptop for supper, so if
> > you’d rather I push the two patches as one folded-together
> > patch let me know. If I don’t hear anything in the next few
> > hours I’ll just push as-is with two commits.
> Folded them as fbe9c4dcc8a0 "bisect: improve option validation
> message".

I saw that. Thank you!

> Perhaps we can filter out False elements first and just take
> the first two?

That does seem much simpler, and probably more efficient... Feel
free to submit your own patch, but this is I think what you were

# HG changeset patch
# User Brandon McCaig <bamccaig at gmail.com>
# Date 1497419027 14400
#      Wed Jun 14 01:43:47 2017 -0400
# Node ID 630766ecca6c0df1256d25868778722f5e312353
# Parent  e65ff29dbeb02ce08e4a64f381ccd37949354dcf
bisect: Simpler approach for option validation message.

Yuya Nishihara gave this suggestion on the mailing list after the
previous patch was queued, and honestly this seems much simpler and
looks more efficient (I'm not too sure how best to wrap the
format string parameters so I took a guess).

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -9,7 +9,6 @@
 import difflib
 import errno
-import itertools
 import os
 import re
 import sys
@@ -781,9 +780,11 @@
         '--skip': skip,
-    for left, right in itertools.combinations(sorted(incompatibles), 2):
-        if incompatibles[left] and incompatibles[right]:
-            raise error.Abort(_('%s and %s are incompatible') % (left, right))
+    enabled = [x for x in incompatibles if incompatibles[x]]
+    if len(enabled) > 1:
+        raise error.Abort(_('%s and %s are incompatible') %
+                            tuple(sorted(enabled)[0:2]))
     if reset:


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.};

-------------- 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/20170614/8d187e2c/attachment.sig>

More information about the Mercurial-devel mailing list