Patchwork phases: pass phase names to hooks instead of internal values

login
register
mail settings
Submitter Kevin Bullock
Date Oct. 18, 2017, 5:38 p.m.
Message ID <b4e14b2c20b220153ae4.1508348283@ingalls.star.local>
Download mbox | patch
Permalink /patch/25204/
State Accepted
Headers show

Comments

Kevin Bullock - Oct. 18, 2017, 5:38 p.m.
# HG changeset patch
# User Kevin Bullock <kbullock+mercurial@ringworld.org>
# Date 1508347193 18000
#      Wed Oct 18 12:19:53 2017 -0500
# Node ID b4e14b2c20b220153ae4f192a4332d40308d4d18
# Parent  2a098c601e7151bde89aa7ee4c555fc6679756dc
phases: pass phase names to hooks instead of internal values
Augie Fackler - Oct. 18, 2017, 6:44 p.m.
> On Oct 18, 2017, at 13:38, Kevin Bullock <kbullock+mercurial@ringworld.org> wrote:
> 
> # HG changeset patch
> # User Kevin Bullock <kbullock+mercurial@ringworld.org>
> # Date 1508347193 18000
> #      Wed Oct 18 12:19:53 2017 -0500
> # Node ID b4e14b2c20b220153ae4f192a4332d40308d4d18
> # Parent  2a098c601e7151bde89aa7ee4c555fc6679756dc
> phases: pass phase names to hooks instead of internal values

Seems obviously correct, queued, thanks

> 
> diff --git a/mercurial/phases.py b/mercurial/phases.py
> --- a/mercurial/phases.py
> +++ b/mercurial/phases.py
> @@ -660,7 +660,7 @@ def preparehookargs(node, old, new):
>     if old is None:
>         old = ''
>     else:
> -        old = '%s' % old
> +        old = phasenames[old]
>     return {'node': node,
>             'oldphase': old,
> -            'phase': '%s' % new}
> +            'phase': phasenames[new]}
> diff --git a/tests/test-phases.t b/tests/test-phases.t
> --- a/tests/test-phases.t
> +++ b/tests/test-phases.t
> @@ -28,7 +28,7 @@ Cannot change null revision phase
> 
>   $ mkcommit A
>   test-debug-phase: new rev 0:  x -> 1
> -  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 1
> +  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> draft
> 
> New commit are draft by default
> 
> @@ -39,7 +39,7 @@ Following commit are draft too
> 
>   $ mkcommit B
>   test-debug-phase: new rev 1:  x -> 1
> -  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 1
> +  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> draft
> 
>   $ hglog
>   1 1 B
> @@ -50,8 +50,8 @@ Draft commit are properly created over p
>   $ hg phase --public .
>   test-debug-phase: move rev 0: 1 -> 0
>   test-debug-phase: move rev 1: 1 -> 0
> -  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  1 -> 0
> -  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  1 -> 0
> +  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  draft -> public
> +  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> public
>   $ hg phase
>   1: public
>   $ hglog
> @@ -60,10 +60,10 @@ Draft commit are properly created over p
> 
>   $ mkcommit C
>   test-debug-phase: new rev 2:  x -> 1
> -  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 1
> +  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> draft
>   $ mkcommit D
>   test-debug-phase: new rev 3:  x -> 1
> -  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 1
> +  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> draft
> 
>   $ hglog
>   3 1 D
> @@ -75,7 +75,7 @@ Test creating changeset as secret
> 
>   $ mkcommit E --config phases.new-commit='secret'
>   test-debug-phase: new rev 4:  x -> 2
> -  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:   -> 2
> +  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:   -> secret
>   $ hglog
>   4 2 E
>   3 1 D
> @@ -87,7 +87,7 @@ Test the secret property is inherited
> 
>   $ mkcommit H
>   test-debug-phase: new rev 5:  x -> 2
> -  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:   -> 2
> +  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:   -> secret
>   $ hglog
>   5 2 H
>   4 2 E
> @@ -102,7 +102,7 @@ Even on merge
>   $ mkcommit "B'"
>   test-debug-phase: new rev 6:  x -> 1
>   created new head
> -  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 1
> +  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> draft
>   $ hglog
>   6 1 B'
>   5 2 H
> @@ -119,7 +119,7 @@ Even on merge
>   4: secret
>   $ hg ci -m "merge B' and E"
>   test-debug-phase: new rev 7:  x -> 2
> -  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:   -> 2
> +  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:   -> secret
> 
>   $ hglog
>   7 2 merge B' and E
> @@ -167,11 +167,11 @@ Test secret changeset are not pushed
>   test-debug-phase: new rev 2:  x -> 1
>   test-debug-phase: new rev 3:  x -> 1
>   test-debug-phase: new rev 4:  x -> 1
> -  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 0
> -  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 0
> -  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 1
> -  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 1
> -  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 1
> +  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> public
> +  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> public
> +  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> draft
> +  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> draft
> +  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> draft
>   $ hglog
>   7 2 merge B' and E
>   6 1 B'
> @@ -198,7 +198,7 @@ visible shared between the initial repo 
>   $ hg up -q 4 # B'
>   $ mkcommit Z --config phases.new-commit=secret
>   test-debug-phase: new rev 5:  x -> 2
> -  test-hook-close-phase: 2713879da13d6eea1ff22b442a5a87cb31a7ce6a:   -> 2
> +  test-hook-close-phase: 2713879da13d6eea1ff22b442a5a87cb31a7ce6a:   -> secret
>   $ hg phase .
>   5: secret
> 
> @@ -210,7 +210,7 @@ head shadowed by the remote secret head.
>   $ mkcommit I
>   test-debug-phase: new rev 8:  x -> 1
>   created new head
> -  test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061:   -> 1
> +  test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061:   -> draft
>   $ hg push ../push-dest
>   pushing to ../push-dest
>   searching for changes
> @@ -219,7 +219,7 @@ head shadowed by the remote secret head.
>   adding file changes
>   added 1 changesets with 1 changes to 1 files (+1 heads)
>   test-debug-phase: new rev 6:  x -> 1
> -  test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061:   -> 1
> +  test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061:   -> draft
> 
> :note: The "(+1 heads)" is wrong as we do not had any visible head
> 
> @@ -273,11 +273,11 @@ Test secret changeset are not pull
>   test-debug-phase: new rev 2:  x -> 0
>   test-debug-phase: new rev 3:  x -> 0
>   test-debug-phase: new rev 4:  x -> 0
> -  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 0
> -  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 0
> -  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 0
> -  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 0
> -  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 0
> +  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> public
> +  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> public
> +  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> public
> +  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> public
> +  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> public
>   (run 'hg heads' to see heads, 'hg merge' to merge)
>   $ hglog
>   4 0 B'
> @@ -303,11 +303,11 @@ Test secret changeset are not cloned
>   test-debug-phase: new rev 2:  x -> 0
>   test-debug-phase: new rev 3:  x -> 0
>   test-debug-phase: new rev 4:  x -> 0
> -  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 0
> -  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 0
> -  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 0
> -  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 0
> -  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 0
> +  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> public
> +  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> public
> +  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> public
> +  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> public
> +  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> public
>   $ hglog -R clone-dest
>   4 0 B'
>   3 0 D
> @@ -507,7 +507,7 @@ move changeset forward
> 
>   $ hg phase --public -r 2
>   test-debug-phase: move rev 2: 1 -> 0
> -  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  1 -> 0
> +  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  draft -> public
>   $ hg log -G --template "{rev} {phase} {desc}\n"
>   @    7 secret merge B' and E
>   |\
> @@ -532,7 +532,7 @@ move changeset backward
> 
>   $ hg phase --draft --force 2
>   test-debug-phase: move rev 2: 0 -> 1
> -  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  0 -> 1
> +  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  public -> draft
>   $ hg log -G --template "{rev} {phase} {desc}\n"
>   @    7 secret merge B' and E
>   |\
> @@ -556,8 +556,8 @@ move changeset forward and backward
>   $ hg phase --draft --force 1::4
>   test-debug-phase: move rev 1: 0 -> 1
>   test-debug-phase: move rev 4: 2 -> 1
> -  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  0 -> 1
> -  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  2 -> 1
> +  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  public -> draft
> +  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  secret -> draft
>   $ hg log -G --template "{rev} {phase} {desc}\n"
>   @    7 secret merge B' and E
>   |\
> @@ -584,15 +584,15 @@ test partial failure
>   test-debug-phase: move rev 4: 1 -> 0
>   test-debug-phase: move rev 6: 1 -> 0
>   test-debug-phase: move rev 7: 2 -> 0
> -  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  1 -> 0
> -  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  1 -> 0
> -  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  1 -> 0
> -  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  1 -> 0
> -  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:  1 -> 0
> -  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  2 -> 0
> +  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> public
> +  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  draft -> public
> +  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  draft -> public
> +  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  draft -> public
> +  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:  draft -> public
> +  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  secret -> public
>   $ hg phase --draft '5 or 7'
>   test-debug-phase: move rev 5: 2 -> 1
> -  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  2 -> 1
> +  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  secret -> draft
>   cannot move 1 changesets to a higher phase, use --force
>   phase changed for 1 changesets
>   [1]
> @@ -652,13 +652,13 @@ test hidden changeset are not cloned as 
>   test-debug-phase: new rev 4:  x -> 0
>   test-debug-phase: new rev 5:  x -> 0
>   test-debug-phase: new rev 6:  x -> 0
> -  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 0
> -  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 0
> -  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 0
> -  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 0
> -  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:   -> 0
> -  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 0
> -  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:   -> 0
> +  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> public
> +  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> public
> +  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> public
> +  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> public
> +  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:   -> public
> +  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> public
> +  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:   -> public
>   updating to branch default
>   6 files updated, 0 files merged, 0 files removed, 0 files unresolved
>   $ cd clonewithobs
> @@ -740,10 +740,10 @@ Check that pretxnclose-phase hook can co
>   test-debug-phase: move rev 4: 0 -> 2
>   test-debug-phase: move rev 5: 1 -> 2
>   test-debug-phase: move rev 7: 0 -> 2
> -  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  0 -> 2
> -  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  0 -> 2
> -  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  1 -> 2
> -  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  0 -> 2
> +  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  public -> secret
> +  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  public -> secret
> +  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  draft -> secret
> +  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  public -> secret
>   $ hg log -G -T phases
>   @    changeset:   7:17a481b3bccb
>   |\   tag:         tip
> @@ -796,7 +796,7 @@ Install a hook that prevent b3325c91a4d9
> 
>   $ cat >> .hg/hgrc << EOF
>> [hooks]
> -  > pretxnclose-phase.nopublish_D = (echo \$HG_NODE| grep -v b3325c91a4d9>/dev/null) || [ 0 -lt \$HG_PHASE ]
> +  > pretxnclose-phase.nopublish_D = (echo \$HG_NODE| grep -v b3325c91a4d9>/dev/null) || [ 'public' != \$HG_PHASE ]
>> EOF
> 
> Try various actions. only the draft move should succeed
> @@ -815,9 +815,9 @@ Try various actions. only the draft move
>   test-debug-phase: move rev 3: 2 -> 1
>   test-debug-phase: move rev 4: 2 -> 1
>   test-debug-phase: move rev 7: 2 -> 1
> -  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  2 -> 1
> -  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  2 -> 1
> -  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  2 -> 1
> +  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  secret -> draft
> +  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  secret -> draft
> +  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  secret -> draft
>   $ hg phase --public 17a481b3bccb
>   transaction abort!
>   rollback completed
> diff --git a/tests/test-push-http.t b/tests/test-push-http.t
> --- a/tests/test-push-http.t
> +++ b/tests/test-push-http.t
> @@ -70,8 +70,8 @@ expect success
>   remote: adding manifests
>   remote: adding file changes
>   remote: added 1 changesets with 1 changes to 1 files
> -  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  1 -> 0
> -  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> 0
> +  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  draft -> public
> +  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> public
>   remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
>   % serve errors
>   $ hg rollback
> @@ -88,8 +88,8 @@ expect success, server lacks the httphea
>   remote: adding manifests
>   remote: adding file changes
>   remote: added 1 changesets with 1 changes to 1 files
> -  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  1 -> 0
> -  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> 0
> +  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  draft -> public
> +  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> public
>   remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
>   % serve errors
>   $ hg rollback
> @@ -106,8 +106,8 @@ expect success, server lacks the unbundl
>   remote: adding manifests
>   remote: adding file changes
>   remote: added 1 changesets with 1 changes to 1 files
> -  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  1 -> 0
> -  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> 0
> +  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  draft -> public
> +  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> public
>   remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
>   % serve errors
>   $ hg rollback

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -660,7 +660,7 @@  def preparehookargs(node, old, new):
     if old is None:
         old = ''
     else:
-        old = '%s' % old
+        old = phasenames[old]
     return {'node': node,
             'oldphase': old,
-            'phase': '%s' % new}
+            'phase': phasenames[new]}
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -28,7 +28,7 @@  Cannot change null revision phase
 
   $ mkcommit A
   test-debug-phase: new rev 0:  x -> 1
-  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 1
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> draft
 
 New commit are draft by default
 
@@ -39,7 +39,7 @@  Following commit are draft too
 
   $ mkcommit B
   test-debug-phase: new rev 1:  x -> 1
-  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 1
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> draft
 
   $ hglog
   1 1 B
@@ -50,8 +50,8 @@  Draft commit are properly created over p
   $ hg phase --public .
   test-debug-phase: move rev 0: 1 -> 0
   test-debug-phase: move rev 1: 1 -> 0
-  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  1 -> 0
-  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  1 -> 0
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  draft -> public
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> public
   $ hg phase
   1: public
   $ hglog
@@ -60,10 +60,10 @@  Draft commit are properly created over p
 
   $ mkcommit C
   test-debug-phase: new rev 2:  x -> 1
-  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 1
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> draft
   $ mkcommit D
   test-debug-phase: new rev 3:  x -> 1
-  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 1
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> draft
 
   $ hglog
   3 1 D
@@ -75,7 +75,7 @@  Test creating changeset as secret
 
   $ mkcommit E --config phases.new-commit='secret'
   test-debug-phase: new rev 4:  x -> 2
-  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:   -> 2
+  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:   -> secret
   $ hglog
   4 2 E
   3 1 D
@@ -87,7 +87,7 @@  Test the secret property is inherited
 
   $ mkcommit H
   test-debug-phase: new rev 5:  x -> 2
-  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:   -> 2
+  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:   -> secret
   $ hglog
   5 2 H
   4 2 E
@@ -102,7 +102,7 @@  Even on merge
   $ mkcommit "B'"
   test-debug-phase: new rev 6:  x -> 1
   created new head
-  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 1
+  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> draft
   $ hglog
   6 1 B'
   5 2 H
@@ -119,7 +119,7 @@  Even on merge
   4: secret
   $ hg ci -m "merge B' and E"
   test-debug-phase: new rev 7:  x -> 2
-  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:   -> 2
+  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:   -> secret
 
   $ hglog
   7 2 merge B' and E
@@ -167,11 +167,11 @@  Test secret changeset are not pushed
   test-debug-phase: new rev 2:  x -> 1
   test-debug-phase: new rev 3:  x -> 1
   test-debug-phase: new rev 4:  x -> 1
-  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 0
-  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 0
-  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 1
-  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 1
-  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 1
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> public
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> public
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> draft
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> draft
+  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> draft
   $ hglog
   7 2 merge B' and E
   6 1 B'
@@ -198,7 +198,7 @@  visible shared between the initial repo 
   $ hg up -q 4 # B'
   $ mkcommit Z --config phases.new-commit=secret
   test-debug-phase: new rev 5:  x -> 2
-  test-hook-close-phase: 2713879da13d6eea1ff22b442a5a87cb31a7ce6a:   -> 2
+  test-hook-close-phase: 2713879da13d6eea1ff22b442a5a87cb31a7ce6a:   -> secret
   $ hg phase .
   5: secret
 
@@ -210,7 +210,7 @@  head shadowed by the remote secret head.
   $ mkcommit I
   test-debug-phase: new rev 8:  x -> 1
   created new head
-  test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061:   -> 1
+  test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061:   -> draft
   $ hg push ../push-dest
   pushing to ../push-dest
   searching for changes
@@ -219,7 +219,7 @@  head shadowed by the remote secret head.
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
   test-debug-phase: new rev 6:  x -> 1
-  test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061:   -> 1
+  test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061:   -> draft
 
 :note: The "(+1 heads)" is wrong as we do not had any visible head
 
@@ -273,11 +273,11 @@  Test secret changeset are not pull
   test-debug-phase: new rev 2:  x -> 0
   test-debug-phase: new rev 3:  x -> 0
   test-debug-phase: new rev 4:  x -> 0
-  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 0
-  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 0
-  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 0
-  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 0
-  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 0
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> public
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> public
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> public
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> public
+  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> public
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hglog
   4 0 B'
@@ -303,11 +303,11 @@  Test secret changeset are not cloned
   test-debug-phase: new rev 2:  x -> 0
   test-debug-phase: new rev 3:  x -> 0
   test-debug-phase: new rev 4:  x -> 0
-  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 0
-  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 0
-  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 0
-  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 0
-  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 0
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> public
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> public
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> public
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> public
+  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> public
   $ hglog -R clone-dest
   4 0 B'
   3 0 D
@@ -507,7 +507,7 @@  move changeset forward
 
   $ hg phase --public -r 2
   test-debug-phase: move rev 2: 1 -> 0
-  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  1 -> 0
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  draft -> public
   $ hg log -G --template "{rev} {phase} {desc}\n"
   @    7 secret merge B' and E
   |\
@@ -532,7 +532,7 @@  move changeset backward
 
   $ hg phase --draft --force 2
   test-debug-phase: move rev 2: 0 -> 1
-  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  0 -> 1
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  public -> draft
   $ hg log -G --template "{rev} {phase} {desc}\n"
   @    7 secret merge B' and E
   |\
@@ -556,8 +556,8 @@  move changeset forward and backward
   $ hg phase --draft --force 1::4
   test-debug-phase: move rev 1: 0 -> 1
   test-debug-phase: move rev 4: 2 -> 1
-  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  0 -> 1
-  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  2 -> 1
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  public -> draft
+  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  secret -> draft
   $ hg log -G --template "{rev} {phase} {desc}\n"
   @    7 secret merge B' and E
   |\
@@ -584,15 +584,15 @@  test partial failure
   test-debug-phase: move rev 4: 1 -> 0
   test-debug-phase: move rev 6: 1 -> 0
   test-debug-phase: move rev 7: 2 -> 0
-  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  1 -> 0
-  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  1 -> 0
-  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  1 -> 0
-  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  1 -> 0
-  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:  1 -> 0
-  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  2 -> 0
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  draft -> public
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:  draft -> public
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  draft -> public
+  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  draft -> public
+  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:  draft -> public
+  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  secret -> public
   $ hg phase --draft '5 or 7'
   test-debug-phase: move rev 5: 2 -> 1
-  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  2 -> 1
+  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  secret -> draft
   cannot move 1 changesets to a higher phase, use --force
   phase changed for 1 changesets
   [1]
@@ -652,13 +652,13 @@  test hidden changeset are not cloned as 
   test-debug-phase: new rev 4:  x -> 0
   test-debug-phase: new rev 5:  x -> 0
   test-debug-phase: new rev 6:  x -> 0
-  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 0
-  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 0
-  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 0
-  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 0
-  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:   -> 0
-  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> 0
-  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:   -> 0
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> public
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> public
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> public
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> public
+  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:   -> public
+  test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519:   -> public
+  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:   -> public
   updating to branch default
   6 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd clonewithobs
@@ -740,10 +740,10 @@  Check that pretxnclose-phase hook can co
   test-debug-phase: move rev 4: 0 -> 2
   test-debug-phase: move rev 5: 1 -> 2
   test-debug-phase: move rev 7: 0 -> 2
-  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  0 -> 2
-  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  0 -> 2
-  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  1 -> 2
-  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  0 -> 2
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  public -> secret
+  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  public -> secret
+  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  draft -> secret
+  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  public -> secret
   $ hg log -G -T phases
   @    changeset:   7:17a481b3bccb
   |\   tag:         tip
@@ -796,7 +796,7 @@  Install a hook that prevent b3325c91a4d9
 
   $ cat >> .hg/hgrc << EOF
   > [hooks]
-  > pretxnclose-phase.nopublish_D = (echo \$HG_NODE| grep -v b3325c91a4d9>/dev/null) || [ 0 -lt \$HG_PHASE ]
+  > pretxnclose-phase.nopublish_D = (echo \$HG_NODE| grep -v b3325c91a4d9>/dev/null) || [ 'public' != \$HG_PHASE ]
   > EOF
 
 Try various actions. only the draft move should succeed
@@ -815,9 +815,9 @@  Try various actions. only the draft move
   test-debug-phase: move rev 3: 2 -> 1
   test-debug-phase: move rev 4: 2 -> 1
   test-debug-phase: move rev 7: 2 -> 1
-  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  2 -> 1
-  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  2 -> 1
-  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  2 -> 1
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  secret -> draft
+  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  secret -> draft
+  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  secret -> draft
   $ hg phase --public 17a481b3bccb
   transaction abort!
   rollback completed
diff --git a/tests/test-push-http.t b/tests/test-push-http.t
--- a/tests/test-push-http.t
+++ b/tests/test-push-http.t
@@ -70,8 +70,8 @@  expect success
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
-  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  1 -> 0
-  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> 0
+  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  draft -> public
+  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> public
   remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
   % serve errors
   $ hg rollback
@@ -88,8 +88,8 @@  expect success, server lacks the httphea
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
-  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  1 -> 0
-  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> 0
+  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  draft -> public
+  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> public
   remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
   % serve errors
   $ hg rollback
@@ -106,8 +106,8 @@  expect success, server lacks the unbundl
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
-  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  1 -> 0
-  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> 0
+  remote: phase-move: cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b:  draft -> public
+  remote: phase-move: ba677d0156c1196c1a699fa53f390dcfc3ce3872:   -> public
   remote: changegroup hook: HG_BUNDLE2=1 HG_HOOKNAME=changegroup HG_HOOKTYPE=changegroup HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_NODE_LAST=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_TXNID=TXN:$ID$ HG_URL=remote:http:$LOCALIP: (glob)
   % serve errors
   $ hg rollback