mercurial/commands.py
changeset 45993 c3d0b3c29ec4
parent 45957 89a2afe31e82
child 46029 b86608e97fa8
--- 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 <cmd>' 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