comparison tests/test-bundle-phases.t @ 33031:e8c8d81eb864

bundle: add config option to include phases This adds an experimental.bundle-phases config option to include phase information in bundles. As with the recently added support for bundling obsmarkers, the support for bundling phases is hidden behind the config option until we decide to make a bundlespec v3 that includes phases (and obsmarkers and ...). We could perhaps use the listkeys format for this, but that's considered obsolete according to Pierre-Yves. Instead, we introduce a new "phase-heads" bundle part. The new part contains the phase heads among the set of bundled revisions. It does not include those in secret phase; any head in the bundle that is not mentioned in the phase-heads part is assumed to be secret. As a special case, an empty phase-heads part thus means that any changesets should be added in secret phase. (If we ever add a fourth phase, we'll include secret in the part and we'll add a version number.) For now, phases are only included by "hg bundle", and not by e.g. strip and rebase.
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 22 Jun 2017 10:10:02 -0700
parents
children 8e3021fd1a44
comparison
equal deleted inserted replaced
33030:3e102a8dd52c 33031:e8c8d81eb864
1 $ cat >> $HGRCPATH <<EOF
2 > [experimental]
3 > bundle-phases=yes
4 > [extensions]
5 > strip=
6 > drawdag=$TESTDIR/drawdag.py
7 > EOF
8
9 Set up repo with linear history
10 $ hg init linear
11 $ cd linear
12 $ hg debugdrawdag <<'EOF'
13 > E
14 > |
15 > D
16 > |
17 > C
18 > |
19 > B
20 > |
21 > A
22 > EOF
23 $ hg phase --public A
24 $ hg phase --force --secret D
25 $ hg log -G -T '{desc} {phase}\n'
26 o E secret
27 |
28 o D secret
29 |
30 o C draft
31 |
32 o B draft
33 |
34 o A public
35
36 Phases are restored when unbundling
37 $ hg bundle --base B -r E bundle
38 3 changesets found
39 $ hg debugbundle bundle
40 Stream params: sortdict([('Compression', 'BZ')])
41 changegroup -- "sortdict([('version', '02'), ('nbchanges', '3')])"
42 26805aba1e600a82e93661149f2313866a221a7b
43 f585351a92f85104bff7c284233c338b10eb1df7
44 9bc730a19041f9ec7cb33c626e811aa233efb18c
45 phase-heads -- 'sortdict()'
46 26805aba1e600a82e93661149f2313866a221a7b draft
47 $ hg strip --no-backup C
48 $ hg unbundle -q bundle
49 $ rm bundle
50 $ hg log -G -T '{desc} {phase}\n'
51 o E secret
52 |
53 o D secret
54 |
55 o C draft
56 |
57 o B draft
58 |
59 o A public
60
61 Root revision's phase is preserved
62 $ hg bundle -a bundle
63 5 changesets found
64 $ hg strip --no-backup A
65 $ hg unbundle -q bundle
66 $ rm bundle
67 $ hg log -G -T '{desc} {phase}\n'
68 o E secret
69 |
70 o D secret
71 |
72 o C draft
73 |
74 o B draft
75 |
76 o A public
77
78 Completely public history can be restored
79 $ hg phase --public E
80 $ hg bundle -a bundle
81 5 changesets found
82 $ hg strip --no-backup A
83 $ hg unbundle -q bundle
84 $ rm bundle
85 $ hg log -G -T '{desc} {phase}\n'
86 o E public
87 |
88 o D public
89 |
90 o C public
91 |
92 o B public
93 |
94 o A public
95
96 Direct transition from public to secret can be restored
97 $ hg phase --secret --force D
98 $ hg bundle -a bundle
99 5 changesets found
100 $ hg strip --no-backup A
101 $ hg unbundle -q bundle
102 $ rm bundle
103 $ hg log -G -T '{desc} {phase}\n'
104 o E secret
105 |
106 o D secret
107 |
108 o C public
109 |
110 o B public
111 |
112 o A public
113
114 Revisions within bundle preserve their phase even if parent changes its phase
115 $ hg phase --draft --force B
116 $ hg bundle --base B -r E bundle
117 3 changesets found
118 $ hg strip --no-backup C
119 $ hg phase --public B
120 $ hg unbundle -q bundle
121 $ rm bundle
122 $ hg log -G -T '{desc} {phase}\n'
123 o E secret
124 |
125 o D secret
126 |
127 o C draft
128 |
129 o B public
130 |
131 o A public
132
133 Phase of ancestors of stripped node get advanced to accommodate child
134 $ hg bundle --base B -r E bundle
135 3 changesets found
136 $ hg strip --no-backup C
137 $ hg phase --force --secret B
138 $ hg unbundle -q bundle
139 $ rm bundle
140 $ hg log -G -T '{desc} {phase}\n'
141 o E secret
142 |
143 o D secret
144 |
145 o C draft
146 |
147 o B draft
148 |
149 o A public
150
151 Unbundling advances phases of changesets even if they were already in the repo.
152 To test that, create a bundle of everything in draft phase and then unbundle
153 to see that secret becomes draft, but public remains public.
154 $ hg phase --draft --force A
155 $ hg phase --draft E
156 $ hg bundle -a bundle
157 5 changesets found
158 $ hg phase --public A
159 $ hg phase --secret --force E
160 $ hg unbundle -q bundle
161 $ rm bundle
162 $ hg log -G -T '{desc} {phase}\n'
163 o E draft
164 |
165 o D draft
166 |
167 o C draft
168 |
169 o B draft
170 |
171 o A public
172
173 $ cd ..
174
175 Set up repo with non-linear history
176 $ hg init non-linear
177 $ cd non-linear
178 $ hg debugdrawdag <<'EOF'
179 > D E
180 > |\|
181 > B C
182 > |/
183 > A
184 > EOF
185 $ hg phase --public C
186 $ hg phase --force --secret B
187 $ hg log -G -T '{node|short} {desc} {phase}\n'
188 o 03ca77807e91 E draft
189 |
190 | o 215e7b0814e1 D secret
191 |/|
192 o | dc0947a82db8 C public
193 | |
194 | o 112478962961 B secret
195 |/
196 o 426bada5c675 A public
197
198
199 Restore bundle of entire repo
200 $ hg bundle -a bundle
201 5 changesets found
202 $ hg debugbundle bundle
203 Stream params: sortdict([('Compression', 'BZ')])
204 changegroup -- "sortdict([('version', '02'), ('nbchanges', '5')])"
205 426bada5c67598ca65036d57d9e4b64b0c1ce7a0
206 112478962961147124edd43549aedd1a335e44bf
207 dc0947a82db884575bb76ea10ac97b08536bfa03
208 215e7b0814e1cac8e2614e7284f2a5dc266b4323
209 03ca77807e919db8807c3749086dc36fb478cac0
210 phase-heads -- 'sortdict()'
211 dc0947a82db884575bb76ea10ac97b08536bfa03 public
212 03ca77807e919db8807c3749086dc36fb478cac0 draft
213 $ hg strip --no-backup A
214 $ hg unbundle -q bundle
215 $ rm bundle
216 $ hg log -G -T '{node|short} {desc} {phase}\n'
217 o 03ca77807e91 E draft
218 |
219 | o 215e7b0814e1 D secret
220 |/|
221 o | dc0947a82db8 C public
222 | |
223 | o 112478962961 B secret
224 |/
225 o 426bada5c675 A public
226
227
228 $ hg bundle --base 'A + C' -r D bundle
229 2 changesets found
230 $ hg debugbundle bundle
231 Stream params: sortdict([('Compression', 'BZ')])
232 changegroup -- "sortdict([('version', '02'), ('nbchanges', '2')])"
233 112478962961147124edd43549aedd1a335e44bf
234 215e7b0814e1cac8e2614e7284f2a5dc266b4323
235 phase-heads -- 'sortdict()'
236 $ rm bundle
237
238 $ hg bundle --base A -r D bundle
239 3 changesets found
240 $ hg debugbundle bundle
241 Stream params: sortdict([('Compression', 'BZ')])
242 changegroup -- "sortdict([('version', '02'), ('nbchanges', '3')])"
243 112478962961147124edd43549aedd1a335e44bf
244 dc0947a82db884575bb76ea10ac97b08536bfa03
245 215e7b0814e1cac8e2614e7284f2a5dc266b4323
246 phase-heads -- 'sortdict()'
247 dc0947a82db884575bb76ea10ac97b08536bfa03 public
248 $ rm bundle
249
250 $ hg bundle --base 'B + C' -r 'D + E' bundle
251 2 changesets found
252 $ hg debugbundle bundle
253 Stream params: sortdict([('Compression', 'BZ')])
254 changegroup -- "sortdict([('version', '02'), ('nbchanges', '2')])"
255 215e7b0814e1cac8e2614e7284f2a5dc266b4323
256 03ca77807e919db8807c3749086dc36fb478cac0
257 phase-heads -- 'sortdict()'
258 03ca77807e919db8807c3749086dc36fb478cac0 draft
259 $ rm bundle