Debian Codegraph @

tests/test-obsolete-checkheads.t

raw
1 Check that obsolete properly strip heads
2
3 #testcases bm-v2 bm-v3
4
5 #if bm-v3
6 $ cat <<EOF >> $HGRCPATH
7 > [experimental]
8 > branch-cache-v3=yes
9 > EOF
10 #else
11 $ cat <<EOF >> $HGRCPATH
12 > [experimental]
13 > branch-cache-v3=no
14 > EOF
15 #endif
16
17 $ cat >> $HGRCPATH << EOF
18 > [phases]
19 > # public changeset are not obsolete
20 > publish=false
21 > [command-templates]
22 > log='{node|short} ({phase}) {desc|firstline}\n'
23 > [experimental]
24 > evolution.createmarkers=True
25 > EOF
26 $ mkcommit() {
27 > echo "$1" > "$1"
28 > hg add "$1"
29 > hg ci -m "add $1"
30 > }
31 $ getid() {
32 > hg id --debug -ir "desc('$1')"
33 > }
34
35
36 $ hg init remote
37 $ cd remote
38 $ mkcommit base
39 $ hg phase --public .
40 $ cd ..
41 $ cp -R remote base
42 $ hg clone remote local
43 updating to branch default
44 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
45 $ cd local
46
47 New head replaces old head
48 ==========================
49
50 setup
51 (we add the 1 flags to prevent bumped error during the test)
52
53 $ mkcommit old
54 $ hg push
55 pushing to $TESTTMP/remote
56 searching for changes
57 adding changesets
58 adding manifests
59 adding file changes
60 added 1 changesets with 1 changes to 1 files
61 $ hg up -q '.^'
62 $ mkcommit new
63 created new head
64 $ hg debugobsolete --flags 1 `getid old` `getid new`
65 1 new obsolescence markers
66 obsoleted 1 changesets
67 $ hg log -G --hidden
68 @ 71e3228bffe1 (draft) add new
69 |
70 | x c70b08862e08 (draft) add old
71 |/
72 o b4952fcf48cf (public) add base
73
74 $ cp -R ../remote ../backup1
75
76 old exists remotely as draft. It is obsoleted by new that we now push.
77 Push should not warn about creating new head
78
79 $ hg push
80 pushing to $TESTTMP/remote
81 searching for changes
82 adding changesets
83 adding manifests
84 adding file changes
85 added 1 changesets with 1 changes to 1 files (+1 heads)
86
87 old head is now public (public local version)
88 =============================================
89
90 setup
91
92 $ rm -fr ../remote
93 $ cp -R ../backup1 ../remote
94 $ hg -R ../remote phase --public c70b08862e08
95 $ hg pull -v
96 pulling from $TESTTMP/remote
97 searching for changes
98 no changes found
99 1 local changesets published
100 $ hg log -G --hidden
101 @ 71e3228bffe1 (draft) add new
102 |
103 | o c70b08862e08 (public) add old
104 |/
105 o b4952fcf48cf (public) add base
106
107
108 Abort: old will still be an head because it's public.
109
110 $ hg push
111 pushing to $TESTTMP/remote
112 searching for changes
113 abort: push creates new remote head 71e3228bffe1
114 (merge or see 'hg help push' for details about pushing new heads)
115 [20]
116
117 old head is now public (public remote version)
118 ==============================================
119
120 TODO: Not implemented yet.
121
122 # setup
123 #
124 # $ rm -fr ../remote
125 # $ cp -R ../backup1 ../remote
126 # $ hg -R ../remote phase --public c70b08862e08
127 # $ hg phase --draft --force c70b08862e08
128 # $ hg log -G --hidden
129 # @ 71e3228bffe1 (draft) add new
130 # |
131 # | x c70b08862e08 (draft) add old
132 # |/
133 # o b4952fcf48cf (public) add base
134 #
135 #
136 #
137 # Abort: old will still be an head because it's public.
138 #
139 # $ hg push
140 # pushing to $TESTTMP/remote
141 # searching for changes
142 # abort: push creates new remote head 71e3228bffe1!
143 # (merge or see 'hg help push' for details about pushing new heads)
144 # [255]
145
146 old head is obsolete but replacement is not pushed
147 ==================================================
148
149 setup
150
151 $ rm -fr ../remote
152 $ cp -R ../backup1 ../remote
153 $ hg phase --draft --force '(0::) - 0'
154 $ hg up -q '.^'
155 $ mkcommit other
156 created new head
157 $ hg log -G --hidden
158 @ d7d41ccbd4de (draft) add other
159 |
160 | o 71e3228bffe1 (draft) add new
161 |/
162 | x c70b08862e08 (draft) add old
163 |/
164 o b4952fcf48cf (public) add base
165
166
167 old exists remotely as draft. It is obsoleted by new but we don't push new.
168 Push should abort on new head
169
170 $ hg push -r 'desc("other")'
171 pushing to $TESTTMP/remote
172 searching for changes
173 abort: push creates new remote head d7d41ccbd4de
174 (merge or see 'hg help push' for details about pushing new heads)
175 [20]
176
177
178
179 Both precursors and successors are already know remotely. Descendant adds heads
180 ===============================================================================
181
182 setup. (The obsolete marker is known locally only
183
184 $ cd ..
185 $ rm -rf local
186 $ hg clone remote local
187 updating to branch default
188 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
189 $ cd local
190 $ mkcommit old
191 old already tracked!
192 nothing changed
193 [1]
194 $ hg up -q '.^'
195 $ mkcommit new
196 created new head
197 $ hg push -f
198 pushing to $TESTTMP/remote
199 searching for changes
200 adding changesets
201 adding manifests
202 adding file changes
203 added 1 changesets with 1 changes to 1 files (+1 heads)
204 $ mkcommit desc1
205 $ hg up -q '.^'
206 $ mkcommit desc2
207 created new head
208 $ hg debugobsolete `getid old` `getid new`
209 1 new obsolescence markers
210 obsoleted 1 changesets
211 $ hg log -G --hidden
212 @ 5fe37041cc2b (draft) add desc2
213 |
214 | o a3ef1d111c5f (draft) add desc1
215 |/
216 o 71e3228bffe1 (draft) add new
217 |
218 | x c70b08862e08 (draft) add old
219 |/
220 o b4952fcf48cf (public) add base
221
222 $ hg log -G --hidden -R ../remote
223 o 71e3228bffe1 (draft) add new
224 |
225 | o c70b08862e08 (draft) add old
226 |/
227 @ b4952fcf48cf (public) add base
228
229 $ cp -R ../remote ../backup2
230
231 Push should not warn about adding new heads. We create one, but we'll delete
232 one anyway.
233
234 $ hg push
235 pushing to $TESTTMP/remote
236 searching for changes
237 adding changesets
238 adding manifests
239 adding file changes
240 added 2 changesets with 2 changes to 2 files (+1 heads)
241
242
243 Remote head is unknown but obsoleted by a local changeset
244 =========================================================
245
246 setup
247
248 $ rm -fr ../remote
249 $ cp -R ../backup1 ../remote
250 $ cd ..
251 $ rm -rf local
252 $ hg clone remote local -r 0
253 adding changesets
254 adding manifests
255 adding file changes
256 added 1 changesets with 1 changes to 1 files
257 new changesets b4952fcf48cf
258 updating to branch default
259 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
260 $ cd local
261 $ mkcommit new
262 $ hg -R ../remote id --debug -r tip
263 c70b08862e0838ea6d7c59c85da2f1ed6c8d67da tip
264 $ hg id --debug -r tip
265 71e3228bffe1886550777233d6c97bb5a6b2a650 tip
266 $ hg debugobsolete c70b08862e0838ea6d7c59c85da2f1ed6c8d67da 71e3228bffe1886550777233d6c97bb5a6b2a650
267 1 new obsolescence markers
268 $ hg log -G --hidden
269 @ 71e3228bffe1 (draft) add new
270 |
271 o b4952fcf48cf (public) add base
272
273 $ hg log -G --hidden -R ../remote
274 o c70b08862e08 (draft) add old
275 |
276 @ b4952fcf48cf (public) add base
277
278
279 We do not have enought data to take the right decision, we should fail
280
281 $ hg push
282 pushing to $TESTTMP/remote
283 searching for changes
284 remote has heads on branch 'default' that are not known locally: c70b08862e08
285 abort: push creates new remote head 71e3228bffe1
286 (pull and merge or see 'hg help push' for details about pushing new heads)
287 [20]
288
289 Pulling the missing data makes it work
290
291 $ hg pull
292 pulling from $TESTTMP/remote
293 searching for changes
294 adding changesets
295 adding manifests
296 adding file changes
297 added 1 changesets with 1 changes to 1 files (+1 heads)
298 (1 other changesets obsolete on arrival)
299 (run 'hg heads' to see heads)
300 $ hg push
301 pushing to $TESTTMP/remote
302 searching for changes
303 adding changesets
304 adding manifests
305 adding file changes
306 added 1 changesets with 1 changes to 1 files (+1 heads)
307
308 Old head is pruned without parent data and new unrelated head added
309 ===================================================================
310
311 setup
312
313 $ cd ..
314 $ rm -R remote local
315 $ cp -R backup1 remote
316 $ hg clone remote local -qr c70b08862e08
317 $ cd local
318 $ hg up -q '.^'
319 $ mkcommit new-unrelated
320 created new head
321 $ hg debugobsolete `getid old`
322 1 new obsolescence markers
323 obsoleted 1 changesets
324 $ hg log -G --hidden
325 @ 350a93b716be (draft) add new-unrelated
326 |
327 | x c70b08862e08 (draft) add old
328 |/
329 o b4952fcf48cf (public) add base
330
331
332 $ hg push
333 pushing to $TESTTMP/remote
334 searching for changes
335 abort: push creates new remote head 350a93b716be
336 (merge or see 'hg help push' for details about pushing new heads)
337 [20]