# HG changeset patch # User Mads Kiilerich # Date 2013-11-16 20:46:29 # Node ID 0d32dd60016c58dfaf5bd38a975c0d9beb571b16 # Parent d0097d5818f984465e4f0db184056ee6716e8c72 bisect: --command without --noupdate should flag the parent rev it tested 14913fcb30c6 not only introduced the 'bisect(current)' revset predicate, it also changed how the 'current' revision is used in combination with --command. The new behaviour might be ok for --noupdate where the working directory and its revision shouldn't be used, but it also did that when --command is used to run a command on the currently checked out revision then it could register the test result on the wrong revision. An example: Before, bisect with --command could use the wrong revision when recording the test result: $ hg up -qr 0 $ hg bisect --command "python \"$TESTTMP/script.py\" and some parameters" changeset 31:58c80a7c8a40: bad abort: inconsistent state, 31:58c80a7c8a40 is good and bad Now it works as before and as expected and uses the working directory revision for the --command result: $ hg up -qr 0 $ hg bisect --command "python \"$TESTTMP/script.py\" and some parameters" changeset 0:b99c7b9c8e11: bad ... diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -667,12 +667,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 @@ -461,11 +461,14 @@ test bisecting command > EOF $ chmod +x script.py $ hg bisect -r - $ hg bisect --good tip - $ hg bisect --bad 0 - Testing changeset 15:e7fa0811edb0 (31 changesets remaining, ~4 tests) - 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg up -qr tip $ hg bisect --command "python \"$TESTTMP/script.py\" and some parameters" + changeset 31:58c80a7c8a40: good + abort: cannot bisect (no known bad revisions) + [255] + $ hg up -qr 0 + $ hg bisect --command "python \"$TESTTMP/script.py\" and some parameters" + changeset 0:b99c7b9c8e11: bad changeset 15:e7fa0811edb0: good changeset 7:03750880c6b5: good changeset 3:b53bea5e2fcb: bad @@ -516,6 +519,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 =========================================================