mercurial/hbisect.py
changeset 26587 56b2bcea2529
parent 25952 f0ad094db832
child 27525 cba62f996780
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
    18     hex,
    18     hex,
    19     short,
    19     short,
    20 )
    20 )
    21 from . import (
    21 from . import (
    22     error,
    22     error,
    23     util,
       
    24 )
    23 )
    25 
    24 
    26 def bisect(changelog, state):
    25 def bisect(changelog, state):
    27     """find the next node (if any) for testing during a bisect search.
    26     """find the next node (if any) for testing during a bisect search.
    28     returns a (nodes, number, good) tuple.
    27     returns a (nodes, number, good) tuple.
    72         badrev, ancestors = buildancestors(state['good'], state['bad'])
    71         badrev, ancestors = buildancestors(state['good'], state['bad'])
    73     bad = changelog.node(badrev)
    72     bad = changelog.node(badrev)
    74     if not ancestors: # now we're confused
    73     if not ancestors: # now we're confused
    75         if (len(state['bad']) == 1 and len(state['good']) == 1 and
    74         if (len(state['bad']) == 1 and len(state['good']) == 1 and
    76             state['bad'] != state['good']):
    75             state['bad'] != state['good']):
    77             raise util.Abort(_("starting revisions are not directly related"))
    76             raise error.Abort(_("starting revisions are not directly related"))
    78         raise util.Abort(_("inconsistent state, %s:%s is good and bad")
    77         raise error.Abort(_("inconsistent state, %s:%s is good and bad")
    79                          % (badrev, short(bad)))
    78                          % (badrev, short(bad)))
    80 
    79 
    81     # build children dict
    80     # build children dict
    82     children = {}
    81     children = {}
    83     visit = collections.deque([badrev])
    82     visit = collections.deque([badrev])
   147     if os.path.exists(repo.join("bisect.state")):
   146     if os.path.exists(repo.join("bisect.state")):
   148         for l in repo.vfs("bisect.state"):
   147         for l in repo.vfs("bisect.state"):
   149             kind, node = l[:-1].split()
   148             kind, node = l[:-1].split()
   150             node = repo.lookup(node)
   149             node = repo.lookup(node)
   151             if kind not in state:
   150             if kind not in state:
   152                 raise util.Abort(_("unknown bisect kind %s") % kind)
   151                 raise error.Abort(_("unknown bisect kind %s") % kind)
   153             state[kind].append(node)
   152             state[kind].append(node)
   154     return state
   153     return state
   155 
   154 
   156 
   155 
   157 def save_state(repo, state):
   156 def save_state(repo, state):