[PATCH 2 of 2] bisect with command: ability to skip revision or abort bisection

Alexander Solovyov piranha at piranha.org.ua
Thu Oct 16 12:26:44 CDT 2008


# HG changeset patch
# User Alexander Solovyov <piranha at piranha.org.ua>
# Date 1224175209 -10800
# Node ID 00a3b4b029d5fa0f25ae4649c6a905734a9f7680
# Parent  2be1ba471a40e7fc3a52edbc7a51aafd564bfa49
bisect with command: ability to skip revision or abort bisection

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -276,9 +276,11 @@
     As a shortcut, you can also use the revision argument to mark a
     revision as good or bad without checking it out first.
 
-    If you supply a command it will be used for automatic bisection. Its
-    exit status will be used as flag to mark revision as bad or good (good
-    in case of 0 and bad in any other case).
+    If you supply a command it will be used for automatic bisection. Its exit
+    status will be used as flag to mark revision as bad or good. In case exit
+    status is 0 the revision is marked as good, 125 - skipped, 127 (command not
+    found) - bisection will be aborted and any other status bigger than 0 will
+    mark revision as bad.
     """
     def print_result(nodes, good):
         displayer = cmdutil.show_changeset(ui, repo, {})
@@ -328,10 +330,18 @@
     if command:
         changesets = 1
         while changesets:
-            # check state
-            status = bool(list(os.popen3(command)[2]))
+            # update state
+            status = os.spawnlp(os.P_WAIT, command)
             node = repo.lookup(rev or '.')
-            transition = (status and 'bad' or 'good')
+            if status == 125:
+                transition = "skip"
+            elif status == 0:
+                transition = "good"
+            # status < 0 means process was killed
+            elif status == 127 or status < 0:
+                break
+            else:
+                transition = "bad"
             state[transition].append(node)
             ui.note(_('Changeset %s: %s\n') % (short(node), transition))
             check_state(state, interactive=False)


More information about the Mercurial-devel mailing list