Patchwork bisect: improve option validation message

login
register
mail settings
Submitter Brandon McCaig
Date June 14, 2017, 5:54 a.m.
Message ID <20170614055410.GE18212@test-chamber-1.castopulence.org>
Download mbox | patch
Permalink /patch/21369/
State Accepted
Headers show

Comments

Brandon McCaig - June 14, 2017, 5:54 a.m.
On Wed, Jun 14, 2017 at 01:51:46AM -0400, Brandon McCaig wrote:
> 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).

Sorry, I derped that patch. The parens at the end was meant to be
added to the paragraph before the patch... Here it is again with
less derp.

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


Regards,
Yuya Nishihara - June 14, 2017, 12:48 p.m.
On Wed, 14 Jun 2017 01:54:10 -0400, Brandon McCaig wrote:
> On Wed, Jun 14, 2017 at 01:51:46AM -0400, Brandon McCaig wrote:
> # HG changeset patch
> # User Brandon McCaig <bamccaig@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.

Queued this, thanks.

Patch

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:
         hbisect.resetstate(repo)