D9372: bisect: refactor to work on a list of revspecs

SimonSapin (Simon Sapin) phabricator at mercurial-scm.org
Mon Nov 23 17:18:41 UTC 2020


SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This will allow adding a `--rev` flag that can be passed more than once.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9372

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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



To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list