# HG changeset patch # User Pierre-Yves David # Date 1472005520 -7200 # Node ID 755730fc1e48a5e611d4b5cda33b0726667921d3 # Parent 3528117c7b4e84f2fd4d742285e7f393c261643c bisect: move check_state into the bisect module Now that the function is simpler, we resume our quest to move the logic into the bisect module. In the process, we add basic documentation. diff -r 3528117c7b4e -r 755730fc1e48 mercurial/commands.py --- a/mercurial/commands.py Wed Aug 24 04:23:13 2016 +0200 +++ b/mercurial/commands.py Wed Aug 24 04:25:20 2016 +0200 @@ -835,14 +835,6 @@ Returns 0 on success. """ - def checkstate(state): - 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(): ui.warn(_("(use of 'hg bisect ' is deprecated)\n")) @@ -913,7 +905,7 @@ rev = None # clear for future iterations state[transition].append(ctx.node()) ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition)) - checkstate(state) + hbisect.checkstate(state) # bisect nodes, changesets, bgood = hbisect.bisect(repo.changelog, state) # update to next check @@ -928,7 +920,7 @@ hbisect.printresult(ui, repo, state, displayer, nodes, bgood) return - checkstate(state) + hbisect.checkstate(state) # actually bisect nodes, changesets, good = hbisect.bisect(repo.changelog, state) diff -r 3528117c7b4e -r 755730fc1e48 mercurial/hbisect.py --- a/mercurial/hbisect.py Wed Aug 24 04:23:13 2016 +0200 +++ b/mercurial/hbisect.py Wed Aug 24 04:25:20 2016 +0200 @@ -177,6 +177,17 @@ if repo.vfs.exists("bisect.state"): repo.vfs.unlink("bisect.state") +def checkstate(state): + """check we have both 'good' and 'bad' to define a range + + Raise Abort exception otherwise.""" + 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)')) + def get(repo, status): """ Return a list of revision(s) that match the given status: