diff mercurial/hbisect.py @ 30066:5f93737d0ba8

bisect: move the 'extendrange' to the 'hbisect' module We have a module ready to host any bisect logic. That logic was already isolated in a function so we just migrate it as is.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 24 Aug 2016 04:16:07 +0200
parents ee21ed7fc7a2
children 6e88cd060ba2
line wrap: on
line diff
--- a/mercurial/hbisect.py	Wed Aug 24 04:13:53 2016 +0200
+++ b/mercurial/hbisect.py	Wed Aug 24 04:16:07 2016 +0200
@@ -139,6 +139,19 @@
 
     return ([best_node], tot, good)
 
+def extendrange(repo, state, nodes, good):
+    # bisect is incomplete when it ends on a merge node and
+    # one of the parent was not checked.
+    parents = repo[nodes[0]].parents()
+    if len(parents) > 1:
+        if good:
+            side = state['bad']
+        else:
+            side = state['good']
+        num = len(set(i.node() for i in parents) & set(side))
+        if num == 1:
+            return parents[0].ancestor(parents[1])
+    return None
 
 def load_state(repo):
     state = {'current': [], 'good': [], 'bad': [], 'skip': []}