[PATCH]

Gregg Lind gregg.lind at gmail.com
Sat Apr 21 16:50:26 UTC 2012


# HG changeset patch
# User Gregg Lind <gregg.lind at gmail.com>
# Date 1335026469 18000
# Node ID 06e5c2d746430332e82c663526bbd145e62e63e5
# Parent  55982f62651f1974fcd91197f1c4801cc98a48f2
bisect: bisect -d --dump option  (issue1271)

straw implementation to dump the bisect state/history from
.hg/bisect.state, including help /doc addition.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -488,22 +488,23 @@ def backout(ui, repo, node=None, rev=Non
     return 0

 @command('bisect',
     [('r', 'reset', False, _('reset bisect state')),
     ('g', 'good', False, _('mark changeset good')),
     ('b', 'bad', False, _('mark changeset bad')),
     ('s', 'skip', False, _('skip testing changeset')),
     ('e', 'extend', False, _('extend the bisect range')),
+    ('d', 'dump', False, _('dump most recent bisect to screen (from
.hg/bisect.state)')),
     ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
     ('U', 'noupdate', False, _('do not update to target'))],
-    _("[-gbsr] [-U] [-c CMD] [REV]"))
+    _("[-gbsra] [-U] [-c CMD] [REV]"))
 def bisect(ui, repo, rev=None, extra=None, command=None,
                reset=None, good=None, bad=None, skip=None, extend=None,
-               noupdate=None):
+               noupdate=None,dump=None):
     """subdivision search of changesets

     This command helps to find changesets which introduce problems. To
     use, mark the earliest changeset you know exhibits the problem as
     bad, then mark the latest changeset which is free from the problem
     as good. Bisect will update your working directory to a revision
     for testing (unless the -U/--noupdate option is specified). Once
     you have performed tests, mark the working directory as good or
@@ -560,16 +561,20 @@ def bisect(ui, repo, rev=None, extra=Non
       - see all changesets that took part in the current bisection::

           hg log -r "bisect(range)"

       - with the graphlog extension, you can even get a nice graph::

           hg log --graph -r "bisect(range)"

+      - bisection infomation is stored in ``.hg/bisect.state``::
+
+          hg bisect -d
+
       See :hg:`help revsets` for more about the `bisect()` keyword.

     Returns 0 on success.
     """
     def extendbisectrange(nodes, good):
         # bisect is incomplete when it ends on a merge node and
         # one of the parent was not checked.
         parents = repo[nodes[0]].parents()
@@ -622,25 +627,33 @@ def bisect(ui, repo, rev=None, extra=Non
         ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
         cmd, rev, extra = rev, extra, None
         if cmd == "good":
             good = True
         elif cmd == "bad":
             bad = True
         else:
             reset = True
-    elif extra or good + bad + skip + reset + extend + bool(command) > 1:
+    elif extra or good + bad + skip + reset + extend + dump +
bool(command) > 1:
         raise util.Abort(_('incompatible arguments'))

     if reset:
         p = repo.join("bisect.state")
         if os.path.exists(p):
             os.unlink(p)
         return

+    if dump:
+        p = repo.join("bisect.state")
+        try:
+            ui.write(open(p).read())
+        except:
+            raise util.Abort(_("no bisection underway"))
+        return
+
     state = hbisect.load_state(repo)

     if command:
         changesets = 1
         try:
             while changesets:
                 # update state
                 status = util.system(command, out=ui.fout)


More information about the Mercurial-devel mailing list