# HG changeset patch # User Simon Sapin # Date 1606131939 -3600 # Node ID c3d0b3c29ec4ac4c1389bc76a60560789558fec0 # Parent 7d3c51c728c9e273e2be70778d5afa391153f44c bisect: refactor to work on a list of revspecs This will allow adding a `--rev` flag that can be passed more than once. Differential Revision: https://phab.mercurial-scm.org/D9372 diff -r 7d3c51c728c9 -r c3d0b3c29ec4 mercurial/commands.py --- a/mercurial/commands.py Fri Nov 20 10:35:42 2020 +0100 +++ b/mercurial/commands.py Mon Nov 23 12:45:39 2020 +0100 @@ -907,8 +907,8 @@ def bisect( ui, repo, - rev=None, - extra=None, + positional_1=None, + positional_2=None, command=None, reset=None, good=None, @@ -998,18 +998,22 @@ Returns 0 on success. """ + rev = [] # backward compatibility - if rev in (b"good", b"bad", b"reset", b"init"): + if positional_1 in (b"good", b"bad", b"reset", b"init"): ui.warn(_(b"(use of 'hg bisect ' is deprecated)\n")) - cmd, rev, extra = rev, extra, None + cmd = positional_1 + rev.append(positional_2) if cmd == b"good": good = True elif cmd == b"bad": bad = True else: reset = True - elif extra: + elif positional_2: raise error.InputError(_(b'incompatible arguments')) + elif positional_1 is not None: + rev.append(positional_1) incompatibles = { b'--bad': bad, @@ -1033,12 +1037,13 @@ state = hbisect.load_state(repo) + if rev: + nodes = [repo[i].node() for i in scmutil.revrange(repo, rev)] + else: + nodes = [repo.lookup(b'.')] + # update state if good or bad or skip: - if rev: - nodes = [repo[i].node() for i in scmutil.revrange(repo, [rev])] - else: - nodes = [repo.lookup(b'.')] if good: state[b'good'] += nodes elif bad: @@ -1076,7 +1081,9 @@ if p2 != nullid: raise error.StateError(_(b'current bisect revision is a merge')) if rev: - node = repo[scmutil.revsingle(repo, rev, node)].node() + if not nodes: + raise error.Abort(_(b'empty revision set')) + node = repo[nodes.last()].node() with hbisect.restore_state(repo, state, node): while changesets: # update state