Mercurial > hg-stable
changeset 16648:1388cc711ea7
bisect: set HG_NODE when runing a command
When running a command, set the environment variable HG_NODE to
tell the command which changeset is being visited.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Tue, 08 May 2012 15:31:00 -0700 |
parents | 14913fcb30c6 |
children | 73b8c2554be8 |
files | mercurial/commands.py tests/test-bisect.t |
diffstat | 2 files changed, 46 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Tue May 08 15:29:09 2012 -0700 +++ b/mercurial/commands.py Tue May 08 15:31:00 2012 -0700 @@ -520,10 +520,12 @@ 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 to mark revisions as good or bad: - status 0 means good, 125 means to skip the revision, 127 - (command not found) will abort the bisection, and any other - non-zero exit status means the revision is bad. + The environment variable HG_NODE will contain the ID of the + changeset being tested. The exit status of the command will be + used to mark revisions as good or bad: status 0 means good, 125 + means to skip the revision, 127 (command not found) will abort the + bisection, and any other non-zero exit status means the revision + is bad. .. container:: verbose @@ -665,7 +667,9 @@ # update state state['current'] = [node] hbisect.save_state(repo, state) - status = util.system(command, out=ui.fout) + status = util.system(command, + environ={'HG_NODE': hex(node)}, + out=ui.fout) if status == 125: transition = "skip" elif status == 0:
--- a/tests/test-bisect.t Tue May 08 15:29:09 2012 -0700 +++ b/tests/test-bisect.t Tue May 08 15:31:00 2012 -0700 @@ -473,3 +473,40 @@ date: Thu Jan 01 00:00:06 1970 +0000 summary: msg 6 + + +test bisecting via a command without updating the working dir, and +ensure that the bisect state file is updated before running a test +command + + $ hg update null + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ 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 $HG_NODE --template {rev}`" + > test "$rev" -ge 6 + > EOF + $ chmod +x script.sh + $ hg bisect -r + $ hg bisect --good tip --noupdate + $ hg bisect --bad 0 --noupdate + Testing changeset 15:e7fa0811edb0 (31 changesets remaining, ~4 tests) + $ hg bisect --command "'`pwd`/script.sh' and some params" --noupdate + 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 + + +ensure that we still don't have a working dir + + $ hg parents