Patchwork [4,of,8] bisect: simplify conditional in 'check_state'

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 9, 2016, 8:57 a.m.
Message ID <c0e6a5b2b04938541876.1476003458@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/16972/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Pierre-Yves David - Oct. 9, 2016, 8:57 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1472005393 -7200
#      Wed Aug 24 04:23:13 2016 +0200
# Node ID c0e6a5b2b049385418761b9892096e12afd06237
# Parent  fb1f6d1e179dcba1b078eb32172aca60e0adb287
# EXP-Topic bisect
bisect: simplify conditional in 'check_state'

Now that extra code about "updating" flag have been removed, we can simplify the
condition flow and remove a level.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -836,12 +836,12 @@  def bisect(ui, repo, rev=None, extra=Non
     Returns 0 on success.
     """
     def checkstate(state):
-        if not state['good'] or not state['bad']:
-            if not state['good']:
-                raise error.Abort(_('cannot bisect (no known good revisions)'))
-            else:
-                raise error.Abort(_('cannot bisect (no known bad revisions)'))
-        return True
+        if state['good'] and state['bad']:
+            return True
+        if not state['good']:
+            raise error.Abort(_('cannot bisect (no known good revisions)'))
+        else:
+            raise error.Abort(_('cannot bisect (no known bad revisions)'))
 
     # backward compatibility
     if rev in "good bad reset init".split():