changeset 34876:eb1b964b354b

phases: pass phase names to hooks instead of internal values
author Kevin Bullock <kbullock+mercurial@ringworld.org>
date Wed, 18 Oct 2017 12:19:53 -0500
parents 4f0d4bc63b8a
children eb24f1d1b50b
files mercurial/phases.py tests/test-phases.t tests/test-push-http.t
diffstat 3 files changed, 62 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/phases.py	Wed Oct 18 12:36:23 2017 +0200
+++ b/mercurial/phases.py	Wed Oct 18 12:19:53 2017 -0500
@@ -660,7 +660,7 @@
     if old is None:
         old = ''
     else:
-        old = '%s' % old
+        old = phasenames[old]
     return {'node': node,
             'oldphase': old,
-            'phase': '%s' % new}
+            'phase': phasenames[new]}
--- a/tests/test-phases.t	Wed Oct 18 12:36:23 2017 +0200
+++ b/tests/test-phases.t	Wed Oct 18 12:19:53 2017 -0500
@@ -28,7 +28,7 @@
 
   $ 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 @@
 
   $ 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 @@
   $ 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 @@
 
   $ 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 @@
 
   $ 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 @@
 
   $ 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 @@
   $ 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 @@
   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-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 @@
   $ 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 @@
   $ 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 @@
   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-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-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 @@
 
   $ 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 @@
 
   $ 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 @@
   $ 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-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-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 @@
   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 @@
 
   $ 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 @@
   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
--- a/tests/test-push-http.t	Wed Oct 18 12:36:23 2017 +0200
+++ b/tests/test-push-http.t	Wed Oct 18 12:19:53 2017 -0500
@@ -70,8 +70,8 @@
   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 @@
   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 @@
   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