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.
--- a/mercurial/commands.py Wed Aug 24 04:13:53 2016 +0200
+++ b/mercurial/commands.py Wed Aug 24 04:16:07 2016 +0200
@@ -835,20 +835,6 @@
Returns 0 on success.
"""
- def extendbisectrange(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 print_result(nodes, good):
displayer = cmdutil.show_changeset(ui, repo, {})
if len(nodes) == 1:
@@ -858,7 +844,7 @@
else:
ui.write(_("The first bad revision is:\n"))
displayer.show(repo[nodes[0]])
- extendnode = extendbisectrange(nodes, good)
+ extendnode = hbisect.extendrange(repo, state, nodes, good)
if extendnode is not None:
ui.write(_('Not all ancestors of this changeset have been'
' checked.\nUse bisect --extend to continue the '
@@ -977,7 +963,7 @@
nodes, changesets, good = hbisect.bisect(repo.changelog, state)
if extend:
if not changesets:
- extendnode = extendbisectrange(nodes, good)
+ extendnode = hbisect.extendrange(repo, state, nodes, good)
if extendnode is not None:
ui.write(_("Extending search to changeset %d:%s\n")
% (extendnode.rev(), extendnode))
--- 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': []}