comparison tests/test-phases.t @ 34710:cdf833d7de98

phase: add a dedicated txnclose-phase hook The new 'txnclose-phase' hook expose the phase movement information stored in 'tr.changes['phases]'. To provide a simple and straightforward hook API to the users, we introduce a new hook called for each revision affected. Since a transaction can affect the phase of multiple changesets, updating the existing 'txnclose' hook to expose that information would be more complex. The data for all moves will not fit in environment variables and iterations over each move would be cumbersome. So the introduction of a new dedicated hook is preferred in this changesets. This does not exclude the addition of the full phase movement information to the existing 'txnclose' in the future to help write more complex hooks.
author Boris Feld <boris.feld@octobus.net>
date Sun, 08 Oct 2017 17:50:46 +0200
parents eb586ed5d8ce
children f6d17075608f
comparison
equal deleted inserted replaced
34709:c212947273a7 34710:cdf833d7de98
1 1
2 $ cat >> $HGRCPATH << EOF 2 $ cat >> $HGRCPATH << EOF
3 > [extensions] 3 > [extensions]
4 > phasereport=$TESTDIR/testlib/ext-phase-report.py 4 > phasereport=$TESTDIR/testlib/ext-phase-report.py
5 > [hooks]
6 > txnclose-phase.test = echo "test-hook-close-phase: \$HG_NODE: \$HG_OLDPHASE -> \$HG_PHASE"
5 > EOF 7 > EOF
6 8
7 $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; } 9 $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; }
8 $ mkcommit() { 10 $ mkcommit() {
9 > echo "$1" > "$1" 11 > echo "$1" > "$1"
24 $ hg phase null 26 $ hg phase null
25 -1: public 27 -1: public
26 28
27 $ mkcommit A 29 $ mkcommit A
28 test-debug-phase: new rev 0: x -> 1 30 test-debug-phase: new rev 0: x -> 1
31 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 1
29 32
30 New commit are draft by default 33 New commit are draft by default
31 34
32 $ hglog 35 $ hglog
33 0 1 A 36 0 1 A
34 37
35 Following commit are draft too 38 Following commit are draft too
36 39
37 $ mkcommit B 40 $ mkcommit B
38 test-debug-phase: new rev 1: x -> 1 41 test-debug-phase: new rev 1: x -> 1
42 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 1
39 43
40 $ hglog 44 $ hglog
41 1 1 B 45 1 1 B
42 0 1 A 46 0 1 A
43 47
44 Draft commit are properly created over public one: 48 Draft commit are properly created over public one:
45 49
46 $ hg phase --public . 50 $ hg phase --public .
47 test-debug-phase: move rev 0: 1 -> 0 51 test-debug-phase: move rev 0: 1 -> 0
48 test-debug-phase: move rev 1: 1 -> 0 52 test-debug-phase: move rev 1: 1 -> 0
53 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: 1 -> 0
54 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: 1 -> 0
49 $ hg phase 55 $ hg phase
50 1: public 56 1: public
51 $ hglog 57 $ hglog
52 1 0 B 58 1 0 B
53 0 0 A 59 0 0 A
54 60
55 $ mkcommit C 61 $ mkcommit C
56 test-debug-phase: new rev 2: x -> 1 62 test-debug-phase: new rev 2: x -> 1
63 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 1
57 $ mkcommit D 64 $ mkcommit D
58 test-debug-phase: new rev 3: x -> 1 65 test-debug-phase: new rev 3: x -> 1
66 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 1
59 67
60 $ hglog 68 $ hglog
61 3 1 D 69 3 1 D
62 2 1 C 70 2 1 C
63 1 0 B 71 1 0 B
65 73
66 Test creating changeset as secret 74 Test creating changeset as secret
67 75
68 $ mkcommit E --config phases.new-commit='secret' 76 $ mkcommit E --config phases.new-commit='secret'
69 test-debug-phase: new rev 4: x -> 2 77 test-debug-phase: new rev 4: x -> 2
78 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: -> 2
70 $ hglog 79 $ hglog
71 4 2 E 80 4 2 E
72 3 1 D 81 3 1 D
73 2 1 C 82 2 1 C
74 1 0 B 83 1 0 B
76 85
77 Test the secret property is inherited 86 Test the secret property is inherited
78 87
79 $ mkcommit H 88 $ mkcommit H
80 test-debug-phase: new rev 5: x -> 2 89 test-debug-phase: new rev 5: x -> 2
90 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: -> 2
81 $ hglog 91 $ hglog
82 5 2 H 92 5 2 H
83 4 2 E 93 4 2 E
84 3 1 D 94 3 1 D
85 2 1 C 95 2 1 C
90 100
91 $ hg up -q 1 101 $ hg up -q 1
92 $ mkcommit "B'" 102 $ mkcommit "B'"
93 test-debug-phase: new rev 6: x -> 1 103 test-debug-phase: new rev 6: x -> 1
94 created new head 104 created new head
105 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 1
95 $ hglog 106 $ hglog
96 6 1 B' 107 6 1 B'
97 5 2 H 108 5 2 H
98 4 2 E 109 4 2 E
99 3 1 D 110 3 1 D
106 $ hg phase 117 $ hg phase
107 6: draft 118 6: draft
108 4: secret 119 4: secret
109 $ hg ci -m "merge B' and E" 120 $ hg ci -m "merge B' and E"
110 test-debug-phase: new rev 7: x -> 2 121 test-debug-phase: new rev 7: x -> 2
122 test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: -> 2
111 123
112 $ hglog 124 $ hglog
113 7 2 merge B' and E 125 7 2 merge B' and E
114 6 1 B' 126 6 1 B'
115 5 2 H 127 5 2 H
153 test-debug-phase: new rev 0: x -> 0 165 test-debug-phase: new rev 0: x -> 0
154 test-debug-phase: new rev 1: x -> 0 166 test-debug-phase: new rev 1: x -> 0
155 test-debug-phase: new rev 2: x -> 1 167 test-debug-phase: new rev 2: x -> 1
156 test-debug-phase: new rev 3: x -> 1 168 test-debug-phase: new rev 3: x -> 1
157 test-debug-phase: new rev 4: x -> 1 169 test-debug-phase: new rev 4: x -> 1
170 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 0
171 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 0
172 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 1
173 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 1
174 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 1
158 $ hglog 175 $ hglog
159 7 2 merge B' and E 176 7 2 merge B' and E
160 6 1 B' 177 6 1 B'
161 5 2 H 178 5 2 H
162 4 2 E 179 4 2 E
179 visible shared between the initial repo and the push destination. 196 visible shared between the initial repo and the push destination.
180 197
181 $ hg up -q 4 # B' 198 $ hg up -q 4 # B'
182 $ mkcommit Z --config phases.new-commit=secret 199 $ mkcommit Z --config phases.new-commit=secret
183 test-debug-phase: new rev 5: x -> 2 200 test-debug-phase: new rev 5: x -> 2
201 test-hook-close-phase: 2713879da13d6eea1ff22b442a5a87cb31a7ce6a: -> 2
184 $ hg phase . 202 $ hg phase .
185 5: secret 203 5: secret
186 204
187 We now try to push a new public changeset that descend from the common public 205 We now try to push a new public changeset that descend from the common public
188 head shadowed by the remote secret head. 206 head shadowed by the remote secret head.
190 $ cd ../initialrepo 208 $ cd ../initialrepo
191 $ hg up -q 6 #B' 209 $ hg up -q 6 #B'
192 $ mkcommit I 210 $ mkcommit I
193 test-debug-phase: new rev 8: x -> 1 211 test-debug-phase: new rev 8: x -> 1
194 created new head 212 created new head
213 test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061: -> 1
195 $ hg push ../push-dest 214 $ hg push ../push-dest
196 pushing to ../push-dest 215 pushing to ../push-dest
197 searching for changes 216 searching for changes
198 adding changesets 217 adding changesets
199 adding manifests 218 adding manifests
200 adding file changes 219 adding file changes
201 added 1 changesets with 1 changes to 1 files (+1 heads) 220 added 1 changesets with 1 changes to 1 files (+1 heads)
202 test-debug-phase: new rev 6: x -> 1 221 test-debug-phase: new rev 6: x -> 1
222 test-hook-close-phase: 6d6770faffce199f1fddd1cf87f6f026138cf061: -> 1
203 223
204 :note: The "(+1 heads)" is wrong as we do not had any visible head 224 :note: The "(+1 heads)" is wrong as we do not had any visible head
205 225
206 check that branch cache with "served" filter are properly computed and stored 226 check that branch cache with "served" filter are properly computed and stored
207 227
251 test-debug-phase: new rev 0: x -> 0 271 test-debug-phase: new rev 0: x -> 0
252 test-debug-phase: new rev 1: x -> 0 272 test-debug-phase: new rev 1: x -> 0
253 test-debug-phase: new rev 2: x -> 0 273 test-debug-phase: new rev 2: x -> 0
254 test-debug-phase: new rev 3: x -> 0 274 test-debug-phase: new rev 3: x -> 0
255 test-debug-phase: new rev 4: x -> 0 275 test-debug-phase: new rev 4: x -> 0
276 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 0
277 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 0
278 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 0
279 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 0
280 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 0
256 (run 'hg heads' to see heads, 'hg merge' to merge) 281 (run 'hg heads' to see heads, 'hg merge' to merge)
257 $ hglog 282 $ hglog
258 4 0 B' 283 4 0 B'
259 3 0 D 284 3 0 D
260 2 0 C 285 2 0 C
276 test-debug-phase: new rev 0: x -> 0 301 test-debug-phase: new rev 0: x -> 0
277 test-debug-phase: new rev 1: x -> 0 302 test-debug-phase: new rev 1: x -> 0
278 test-debug-phase: new rev 2: x -> 0 303 test-debug-phase: new rev 2: x -> 0
279 test-debug-phase: new rev 3: x -> 0 304 test-debug-phase: new rev 3: x -> 0
280 test-debug-phase: new rev 4: x -> 0 305 test-debug-phase: new rev 4: x -> 0
306 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 0
307 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 0
308 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 0
309 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 0
310 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 0
281 $ hglog -R clone-dest 311 $ hglog -R clone-dest
282 4 0 B' 312 4 0 B'
283 3 0 D 313 3 0 D
284 2 0 C 314 2 0 C
285 1 0 B 315 1 0 B
475 505
476 (with -r option) 506 (with -r option)
477 507
478 $ hg phase --public -r 2 508 $ hg phase --public -r 2
479 test-debug-phase: move rev 2: 1 -> 0 509 test-debug-phase: move rev 2: 1 -> 0
510 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: 1 -> 0
480 $ hg log -G --template "{rev} {phase} {desc}\n" 511 $ hg log -G --template "{rev} {phase} {desc}\n"
481 @ 7 secret merge B' and E 512 @ 7 secret merge B' and E
482 |\ 513 |\
483 | o 6 draft B' 514 | o 6 draft B'
484 | | 515 | |
499 530
500 (without -r option) 531 (without -r option)
501 532
502 $ hg phase --draft --force 2 533 $ hg phase --draft --force 2
503 test-debug-phase: move rev 2: 0 -> 1 534 test-debug-phase: move rev 2: 0 -> 1
535 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: 0 -> 1
504 $ hg log -G --template "{rev} {phase} {desc}\n" 536 $ hg log -G --template "{rev} {phase} {desc}\n"
505 @ 7 secret merge B' and E 537 @ 7 secret merge B' and E
506 |\ 538 |\
507 | o 6 draft B' 539 | o 6 draft B'
508 | | 540 | |
522 move changeset forward and backward 554 move changeset forward and backward
523 555
524 $ hg phase --draft --force 1::4 556 $ hg phase --draft --force 1::4
525 test-debug-phase: move rev 1: 0 -> 1 557 test-debug-phase: move rev 1: 0 -> 1
526 test-debug-phase: move rev 4: 2 -> 1 558 test-debug-phase: move rev 4: 2 -> 1
559 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: 0 -> 1
560 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: 2 -> 1
527 $ hg log -G --template "{rev} {phase} {desc}\n" 561 $ hg log -G --template "{rev} {phase} {desc}\n"
528 @ 7 secret merge B' and E 562 @ 7 secret merge B' and E
529 |\ 563 |\
530 | o 6 draft B' 564 | o 6 draft B'
531 | | 565 | |
548 test-debug-phase: move rev 2: 1 -> 0 582 test-debug-phase: move rev 2: 1 -> 0
549 test-debug-phase: move rev 3: 1 -> 0 583 test-debug-phase: move rev 3: 1 -> 0
550 test-debug-phase: move rev 4: 1 -> 0 584 test-debug-phase: move rev 4: 1 -> 0
551 test-debug-phase: move rev 6: 1 -> 0 585 test-debug-phase: move rev 6: 1 -> 0
552 test-debug-phase: move rev 7: 2 -> 0 586 test-debug-phase: move rev 7: 2 -> 0
587 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: 1 -> 0
588 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: 1 -> 0
589 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: 1 -> 0
590 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: 1 -> 0
591 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: 1 -> 0
592 test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: 2 -> 0
553 $ hg phase --draft '5 or 7' 593 $ hg phase --draft '5 or 7'
554 test-debug-phase: move rev 5: 2 -> 1 594 test-debug-phase: move rev 5: 2 -> 1
595 test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8: 2 -> 1
555 cannot move 1 changesets to a higher phase, use --force 596 cannot move 1 changesets to a higher phase, use --force
556 phase changed for 1 changesets 597 phase changed for 1 changesets
557 [1] 598 [1]
558 $ hg log -G --template "{rev} {phase} {desc}\n" 599 $ hg log -G --template "{rev} {phase} {desc}\n"
559 @ 7 public merge B' and E 600 @ 7 public merge B' and E
609 test-debug-phase: new rev 2: x -> 0 650 test-debug-phase: new rev 2: x -> 0
610 test-debug-phase: new rev 3: x -> 0 651 test-debug-phase: new rev 3: x -> 0
611 test-debug-phase: new rev 4: x -> 0 652 test-debug-phase: new rev 4: x -> 0
612 test-debug-phase: new rev 5: x -> 0 653 test-debug-phase: new rev 5: x -> 0
613 test-debug-phase: new rev 6: x -> 0 654 test-debug-phase: new rev 6: x -> 0
655 test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256: -> 0
656 test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56: -> 0
657 test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757: -> 0
658 test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e: -> 0
659 test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde: -> 0
660 test-hook-close-phase: cf9fe039dfd67e829edf6522a45de057b5c86519: -> 0
661 test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af: -> 0
614 updating to branch default 662 updating to branch default
615 6 files updated, 0 files merged, 0 files removed, 0 files unresolved 663 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
616 $ cd clonewithobs 664 $ cd clonewithobs
617 $ hg log -G --template "{rev} {phase} {desc}\n" 665 $ hg log -G --template "{rev} {phase} {desc}\n"
618 @ 6 public merge B' and E 666 @ 6 public merge B' and E