Patchwork [2,of,2,stable] bisect: --command without --noupdate should flag the parent rev it tested

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 10, 2013, 5:58 p.m.
Message ID <278f54215117d5fde012.1384106321@localhost.localdomain>
Download mbox | patch
Permalink /patch/2900/
State Superseded
Commit 0d32dd60016c58dfaf5bd38a975c0d9beb571b16
Headers show

Comments

Mads Kiilerich - Nov. 10, 2013, 5:58 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1384105882 -3600
#      Sun Nov 10 18:51:22 2013 +0100
# Branch stable
# Node ID 278f54215117d5fde0122ce366b49180dead23fb
# Parent  a19429a57d1b9386eba4775929a4e82fd3070d74
bisect: --command without --noupdate should flag the parent rev it tested

14913fcb30c6 not only introduced a revset predicate, it also changed how
--noupdate works in combination with --command. But more important: It also
introduced what seems like a bug, that --command would flag the revision
tracked as "current" instead of the parent revision that actually had been used
when running the command. This patch partly restores the old behavior.

1388cc711ea7 made the combination of --command and --noupdate more useful but
did still not clarify exactly what was intended and why. I would expect that it
should use the parent revision or the revision specified with --rev. Starting
out with the 'current' revision (which at this point arguably is more like the
previous revision and already has been tested) seems wrong. Anyway, the
behavior in that case is not changed by this patch.
Matt Mackall - Nov. 22, 2013, 8:37 p.m.
On Sun, 2013-11-10 at 18:58 +0100, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1384105882 -3600
> #      Sun Nov 10 18:51:22 2013 +0100
> # Branch stable
> # Node ID 278f54215117d5fde0122ce366b49180dead23fb
> # Parent  a19429a57d1b9386eba4775929a4e82fd3070d74
> bisect: --command without --noupdate should flag the parent rev it tested

I've spent 15 minutes looking at this and I'm afraid I don't understand
this description. Please provide an example.

> 14913fcb30c6 not only introduced a revset predicate, it also changed how
> --noupdate works in combination with --command. But more important: It also
> introduced what seems like a bug, that --command would flag the revision
> tracked as "current" instead of the parent revision that actually had been used
> when running the command. This patch partly restores the old behavior.

> 1388cc711ea7 made the combination of --command and --noupdate more useful but
> did still not clarify exactly what was intended and why. I would expect that it
> should use the parent revision or the revision specified with --rev. Starting
> out with the 'current' revision (which at this point arguably is more like the
> previous revision and already has been tested) seems wrong. Anyway, the
> behavior in that case is not changed by this patch.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -665,12 +665,13 @@  def bisect(ui, repo, rev=None, extra=Non
 
     if command:
         changesets = 1
-        try:
-            node = state['current'][0]
-        except LookupError:
-            if noupdate:
+        if noupdate:
+            try:
+                node = state['current'][0]
+            except LookupError:
                 raise util.Abort(_('current bisect revision is unknown - '
                                    'start a new bisect to fix'))
+        else:
             node, p2 = repo.dirstate.parents()
             if p2 != nullid:
                 raise util.Abort(_('current bisect revision is a merge'))
diff --git a/tests/test-bisect.t b/tests/test-bisect.t
--- a/tests/test-bisect.t
+++ b/tests/test-bisect.t
@@ -516,6 +516,39 @@  ensure that we still don't have a workin
   $ hg parents
 
 
+test the same case, this time with updating
+
+  $ cat > script.sh <<'EOF'
+  > #!/bin/sh
+  > test -n "$HG_NODE" || (echo HG_NODE missing; exit 127)
+  > current="`hg log -r \"bisect(current)\" --template {node}`"
+  > test "$current" = "$HG_NODE" || (echo current is bad: $current; exit 127)
+  > rev="`hg log -r . --template {rev}`"
+  > test "$rev" -ge 6
+  > EOF
+  $ chmod +x script.sh
+  $ hg bisect -r
+  $ hg up -qr tip
+  $ hg bisect --command "sh \"$TESTTMP/script.sh\" and some params"
+  changeset 31:58c80a7c8a40: good
+  abort: cannot bisect (no known bad revisions)
+  [255]
+  $ hg up -qr 0
+  $ hg bisect --command "sh \"$TESTTMP/script.sh\" and some params"
+  changeset 0:b99c7b9c8e11: bad
+  changeset 15:e7fa0811edb0: good
+  changeset 7:03750880c6b5: good
+  changeset 3:b53bea5e2fcb: bad
+  changeset 5:7874a09ea728: bad
+  changeset 6:a3d5c6fdf0d3: good
+  The first good revision is:
+  changeset:   6:a3d5c6fdf0d3
+  user:        test
+  date:        Thu Jan 01 00:00:06 1970 +0000
+  summary:     msg 6
+  
+
+
 Check that bisect does not break on obsolete changesets
 =========================================================