##// END OF EJS Templates
tests: add test showing how `hg fix -s` deals with obsolete and orphan nodes...
Martin von Zweigbergk -
r46399:e281a1ac default draft
parent child Browse files
Show More
@@ -1,521 +1,556 b''
1 1 A script that implements uppercasing all letters in a file.
2 2
3 3 $ UPPERCASEPY="$TESTTMP/uppercase.py"
4 4 $ cat > $UPPERCASEPY <<EOF
5 5 > import sys
6 6 > from mercurial.utils.procutil import setbinary
7 7 > setbinary(sys.stdin)
8 8 > setbinary(sys.stdout)
9 9 > sys.stdout.write(sys.stdin.read().upper())
10 10 > EOF
11 11 $ TESTLINES="foo\nbar\nbaz\n"
12 12 $ printf $TESTLINES | "$PYTHON" $UPPERCASEPY
13 13 FOO
14 14 BAR
15 15 BAZ
16 16
17 17 Tests for the fix extension's behavior around non-trivial history topologies.
18 18 Looks for correct incremental fixing and reproduction of parent/child
19 19 relationships. We indicate fixed file content by uppercasing it.
20 20
21 21 $ cat >> $HGRCPATH <<EOF
22 22 > [extensions]
23 23 > fix =
24 24 > strip =
25 > debugdrawdag=$TESTDIR/drawdag.py
25 26 > [fix]
26 27 > uppercase-whole-file:command="$PYTHON" $UPPERCASEPY
27 28 > uppercase-whole-file:pattern=set:**
28 29 > EOF
29 30
30 31 This tests the only behavior that should really be affected by obsolescence, so
31 32 we'll test it with evolution off and on. This only changes the revision
32 33 numbers, if all is well.
33 34
34 35 #testcases obsstore-off obsstore-on
35 36 #if obsstore-on
36 37 $ cat >> $HGRCPATH <<EOF
37 38 > [experimental]
38 39 > evolution.createmarkers=True
39 40 > evolution.allowunstable=True
40 41 > EOF
41 42 #endif
42 43
43 44 Setting up the test topology. Scroll down to see the graph produced. We make it
44 45 clear which files were modified in each revision. It's enough to test at the
45 46 file granularity, because that demonstrates which baserevs were diffed against.
46 47 The computation of changed lines is orthogonal and tested separately.
47 48
48 49 $ hg init repo
49 50 $ cd repo
50 51
51 52 $ printf "aaaa\n" > a
52 53 $ hg commit -Am "change A"
53 54 adding a
54 55 $ printf "bbbb\n" > b
55 56 $ hg commit -Am "change B"
56 57 adding b
57 58 $ printf "cccc\n" > c
58 59 $ hg commit -Am "change C"
59 60 adding c
60 61 $ hg checkout 0
61 62 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
62 63 $ printf "dddd\n" > d
63 64 $ hg commit -Am "change D"
64 65 adding d
65 66 created new head
66 67 $ hg merge -r 2
67 68 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
68 69 (branch merge, don't forget to commit)
69 70 $ printf "eeee\n" > e
70 71 $ hg commit -Am "change E"
71 72 adding e
72 73 $ hg checkout 0
73 74 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
74 75 $ printf "ffff\n" > f
75 76 $ hg commit -Am "change F"
76 77 adding f
77 78 created new head
78 79 $ hg checkout 0
79 80 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
80 81 $ printf "gggg\n" > g
81 82 $ hg commit -Am "change G"
82 83 adding g
83 84 created new head
84 85 $ hg merge -r 5
85 86 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
86 87 (branch merge, don't forget to commit)
87 88 $ printf "hhhh\n" > h
88 89 $ hg commit -Am "change H (child of b53d63e816fb and 0e49f92ee6e9)"
89 90 adding h
90 91 $ hg merge -r 4
91 92 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
92 93 (branch merge, don't forget to commit)
93 94 $ printf "iiii\n" > i
94 95 $ hg commit -Am "change I"
95 96 adding i
96 97 $ hg checkout 2
97 98 0 files updated, 0 files merged, 6 files removed, 0 files unresolved
98 99 $ printf "jjjj\n" > j
99 100 $ hg commit -Am "change J (child of 7f371349286e)"
100 101 adding j
101 102 created new head
102 103 $ hg checkout 7
103 104 3 files updated, 0 files merged, 3 files removed, 0 files unresolved
104 105 $ printf "kkkk\n" > k
105 106 $ hg add
106 107 adding k
107 108
108 109 $ hg log --graph --template '{rev}:{node|short} {desc}\n'
109 110 o 9:884041ccc490 change J (child of 7f371349286e)
110 111 |
111 112 | o 8:b7c772105fd2 change I
112 113 | |\
113 114 | | @ 7:4e7b9312dad2 change H (child of b53d63e816fb and 0e49f92ee6e9)
114 115 | | |\
115 116 | | | o 6:0e49f92ee6e9 change G
116 117 | | | |
117 118 | | o | 5:b53d63e816fb change F
118 119 | | |/
119 120 | o | 4:ddad58af5e51 change E
120 121 |/| |
121 122 | o | 3:c015ebfd2bfe change D
122 123 | |/
123 124 o | 2:7f371349286e change C
124 125 | |
125 126 o | 1:388fdd33fea0 change B
126 127 |/
127 128 o 0:a55a84d97a24 change A
128 129
129 130
130 131 Fix all but the root revision and its four children.
131 132
132 133 $ hg fix -r '2|4|7|8|9' --working-dir
133 134 saved backup bundle to * (glob) (obsstore-off !)
134 135
135 136 The five revisions remain, but the other revisions were fixed and replaced. All
136 137 parent pointers have been accurately set to reproduce the previous topology
137 138 (though it is rendered in a slightly different order now).
138 139
139 140 #if obsstore-on
140 141 $ hg log --graph --template '{rev}:{node|short} {desc}\n'
141 142 o 14:d8d0e7974598 change J (child of 89de0da1d5da)
142 143 |
143 144 | o 13:4fc0b354461e change I
144 145 | |\
145 146 | | @ 12:1c45f3923443 change H (child of b53d63e816fb and 0e49f92ee6e9)
146 147 | | |\
147 148 | o | | 11:d75754455722 change E
148 149 |/| | |
149 150 o | | | 10:89de0da1d5da change C
150 151 | | | |
151 152 | | | o 6:0e49f92ee6e9 change G
152 153 | | | |
153 154 | | o | 5:b53d63e816fb change F
154 155 | | |/
155 156 | o / 3:c015ebfd2bfe change D
156 157 | |/
157 158 o / 1:388fdd33fea0 change B
158 159 |/
159 160 o 0:a55a84d97a24 change A
160 161
161 162 $ C=10
162 163 $ E=11
163 164 $ H=12
164 165 $ I=13
165 166 $ J=14
166 167 #else
167 168 $ hg log --graph --template '{rev}:{node|short} {desc}\n'
168 169 o 9:d8d0e7974598 change J (child of 89de0da1d5da)
169 170 |
170 171 | o 8:4fc0b354461e change I
171 172 | |\
172 173 | | @ 7:1c45f3923443 change H (child of b53d63e816fb and 0e49f92ee6e9)
173 174 | | |\
174 175 | o | | 6:d75754455722 change E
175 176 |/| | |
176 177 o | | | 5:89de0da1d5da change C
177 178 | | | |
178 179 | | | o 4:0e49f92ee6e9 change G
179 180 | | | |
180 181 | | o | 3:b53d63e816fb change F
181 182 | | |/
182 183 | o / 2:c015ebfd2bfe change D
183 184 | |/
184 185 o / 1:388fdd33fea0 change B
185 186 |/
186 187 o 0:a55a84d97a24 change A
187 188
188 189 $ C=5
189 190 $ E=6
190 191 $ H=7
191 192 $ I=8
192 193 $ J=9
193 194 #endif
194 195
195 196 Change C is a root of the set being fixed, so all we fix is what has changed
196 197 since its parent. That parent, change B, is its baserev.
197 198
198 199 $ hg cat -r $C 'set:**'
199 200 aaaa
200 201 bbbb
201 202 CCCC
202 203
203 204 Change E is a merge with only one parent being fixed. Its baserevs are the
204 205 unfixed parent plus the baserevs of the other parent. This evaluates to changes
205 206 B and D. We now have to decide what it means to incrementally fix a merge
206 207 commit. We choose to fix anything that has changed versus any baserev. Only the
207 208 undisturbed content of the common ancestor, change A, is unfixed.
208 209
209 210 $ hg cat -r $E 'set:**'
210 211 aaaa
211 212 BBBB
212 213 CCCC
213 214 DDDD
214 215 EEEE
215 216
216 217 Change H is a merge with neither parent being fixed. This is essentially
217 218 equivalent to the previous case because there is still only one baserev for
218 219 each parent of the merge.
219 220
220 221 $ hg cat -r $H 'set:**'
221 222 aaaa
222 223 FFFF
223 224 GGGG
224 225 HHHH
225 226
226 227 Change I is a merge that has four baserevs; two from each parent. We handle
227 228 multiple baserevs in the same way regardless of how many came from each parent.
228 229 So, fixing change H will fix any files that were not exactly the same in each
229 230 baserev.
230 231
231 232 $ hg cat -r $I 'set:**'
232 233 aaaa
233 234 BBBB
234 235 CCCC
235 236 DDDD
236 237 EEEE
237 238 FFFF
238 239 GGGG
239 240 HHHH
240 241 IIII
241 242
242 243 Change J is a simple case with one baserev, but its baserev is not its parent,
243 244 change C. Its baserev is its grandparent, change B.
244 245
245 246 $ hg cat -r $J 'set:**'
246 247 aaaa
247 248 bbbb
248 249 CCCC
249 250 JJJJ
250 251
251 252 The working copy was dirty, so it is treated much like a revision. The baserevs
252 253 for the working copy are inherited from its parent, change H, because it is
253 254 also being fixed.
254 255
255 256 $ cat *
256 257 aaaa
257 258 FFFF
258 259 GGGG
259 260 HHHH
260 261 KKKK
261 262
262 263 Change A was never a baserev because none of its children were to be fixed.
263 264
264 265 $ cd ..
265 266
266 267
267 268 Test the --source option. We only do this with obsstore on to avoid duplicating
268 269 test code. We rely on the other tests to prove that obsolescence is not an
269 270 important factor here.
270 271
271 272 #if obsstore-on
272 273 $ hg init source-arg
273 274 $ cd source-arg
274 275 $ printf "aaaa\n" > a
275 276 $ hg commit -Am "change A"
276 277 adding a
277 278 $ printf "bbbb\n" > b
278 279 $ hg commit -Am "change B"
279 280 adding b
280 281 $ printf "cccc\n" > c
281 282 $ hg commit -Am "change C"
282 283 adding c
283 284 $ hg checkout 0
284 285 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
285 286 $ printf "dddd\n" > d
286 287 $ hg commit -Am "change D"
287 288 adding d
288 289 created new head
289 290 $ hg log --graph --template '{rev} {desc}\n'
290 291 @ 3 change D
291 292 |
292 293 | o 2 change C
293 294 | |
294 295 | o 1 change B
295 296 |/
296 297 o 0 change A
297 298
298 299
299 300 Test passing 'wdir()' to --source
300 301 $ printf "xxxx\n" > x
301 302 $ hg add x
302 303 $ hg fix -s 'wdir()'
303 304 $ cat *
304 305 aaaa
305 306 dddd
306 307 XXXX
307 308
308 309 Test passing '.' to --source
309 310 $ printf "xxxx\n" > x
310 311 $ hg fix -s .
311 312 $ hg log --graph --template '{rev} {desc}\n'
312 313 @ 4 change D
313 314 |
314 315 | o 2 change C
315 316 | |
316 317 | o 1 change B
317 318 |/
318 319 o 0 change A
319 320
320 321 $ cat *
321 322 aaaa
322 323 DDDD
323 324 XXXX
324 325 $ hg strip -qf 4
325 326 $ hg co -q 3
326 327
327 328 Test passing other branch to --source
328 329 $ printf "xxxx\n" > x
329 330 $ hg add x
330 331 $ hg fix -s 2
331 332 $ hg log --graph --template '{rev} {desc}\n'
332 333 o 4 change C
333 334 |
334 335 | @ 3 change D
335 336 | |
336 337 o | 1 change B
337 338 |/
338 339 o 0 change A
339 340
340 341 $ hg cat -r 4 b c
341 342 bbbb
342 343 CCCC
343 344 $ cat *
344 345 aaaa
345 346 dddd
346 347 xxxx
347 348 $ hg strip -qf 4
348 349
349 350 Test passing multiple revisions to --source
350 351 $ hg fix -s '2 + .'
351 352 $ hg log --graph --template '{rev} {desc}\n'
352 353 @ 5 change D
353 354 |
354 355 | o 4 change C
355 356 | |
356 357 | o 1 change B
357 358 |/
358 359 o 0 change A
359 360
360 361 $ hg cat -r 4 b c
361 362 bbbb
362 363 CCCC
363 364 $ cat *
364 365 aaaa
365 366 DDDD
366 367 XXXX
367 368
368 369 $ cd ..
370
371 $ hg init exclude-obsolete
372 $ cd exclude-obsolete
373 $ hg debugdrawdag <<'EOS'
374 > E C # prune: C
375 > | |
376 > D B # prune: B, D
377 > |/
378 > A
379 > EOS
380 1 new orphan changesets
381 $ hg log --graph --template '{rev} {desc}\n'
382 * 4 E
383 |
384 | x 3 C
385 | |
386 x | 2 D
387 | |
388 | x 1 B
389 |/
390 o 0 A
391
392 $ hg fix -s A
393 abort: fixing obsolete revision could cause divergence
394 [255]
395 $ hg fix -s B
396 abort: fixing obsolete revision could cause divergence
397 [255]
398 $ hg fix -s D
399 abort: fixing obsolete revision could cause divergence
400 [255]
401 $ hg fix -s E
402 $ cd ..
403
369 404 #endif
370 405
371 406 The --all flag should fix anything that wouldn't cause a problem if you fixed
372 407 it, including the working copy. Obsolete revisions are not fixed because that
373 408 could cause divergence. Public revisions would cause an abort because they are
374 409 immutable. We can fix orphans because their successors are still just orphans
375 410 of the original obsolete parent. When obsolesence is off, we're just fixing and
376 411 replacing anything that isn't public.
377 412
378 413 $ hg init fixall
379 414 $ cd fixall
380 415 $ hg fix --all --working-dir
381 416 abort: cannot specify both --working-dir and --all
382 417 [255]
383 418
384 419 #if obsstore-on
385 420 $ printf "one\n" > foo.whole
386 421 $ hg commit -Aqm "first"
387 422 $ hg phase --public
388 423 $ hg tag --local root
389 424 $ printf "two\n" > foo.whole
390 425 $ hg commit -m "second"
391 426 $ printf "three\n" > foo.whole
392 427 $ hg commit -m "third" --secret
393 428 $ hg tag --local secret
394 429 $ hg checkout root
395 430 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
396 431 $ printf "four\n" > foo.whole
397 432 $ hg commit -m "fourth"
398 433 created new head
399 434 $ printf "five\n" > foo.whole
400 435 $ hg commit -m "fifth"
401 436 $ hg tag --local replaced
402 437 $ printf "six\n" > foo.whole
403 438 $ hg commit -m "sixth"
404 439 $ hg checkout replaced
405 440 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
406 441 $ printf "seven\n" > foo.whole
407 442 $ hg commit --amend
408 443 1 new orphan changesets
409 444 $ hg checkout secret
410 445 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
411 446 $ printf "uncommitted\n" > foo.whole
412 447
413 448 $ hg log --graph --template '{rev} {desc} {phase}\n'
414 449 o 6 fifth draft
415 450 |
416 451 | * 5 sixth draft
417 452 | |
418 453 | x 4 fifth draft
419 454 |/
420 455 o 3 fourth draft
421 456 |
422 457 | @ 2 third secret
423 458 | |
424 459 | o 1 second draft
425 460 |/
426 461 o 0 first public
427 462
428 463
429 464 $ hg fix --all
430 465
431 466 $ hg log --graph --template '{rev} {desc}\n' -r 'sort(all(), topo)' --hidden
432 467 o 11 fifth
433 468 |
434 469 o 9 fourth
435 470 |
436 471 | @ 8 third
437 472 | |
438 473 | o 7 second
439 474 |/
440 475 | * 10 sixth
441 476 | |
442 477 | | x 5 sixth
443 478 | |/
444 479 | x 4 fifth
445 480 | |
446 481 | | x 6 fifth
447 482 | |/
448 483 | x 3 fourth
449 484 |/
450 485 | x 2 third
451 486 | |
452 487 | x 1 second
453 488 |/
454 489 o 0 first
455 490
456 491
457 492 $ hg cat -r 7 foo.whole
458 493 TWO
459 494 $ hg cat -r 8 foo.whole
460 495 THREE
461 496 $ hg cat -r 9 foo.whole
462 497 FOUR
463 498 $ hg cat -r 10 foo.whole
464 499 SIX
465 500 $ hg cat -r 11 foo.whole
466 501 SEVEN
467 502 $ cat foo.whole
468 503 UNCOMMITTED
469 504 #else
470 505 $ printf "one\n" > foo.whole
471 506 $ hg commit -Aqm "first"
472 507 $ hg phase --public
473 508 $ hg tag --local root
474 509 $ printf "two\n" > foo.whole
475 510 $ hg commit -m "second"
476 511 $ printf "three\n" > foo.whole
477 512 $ hg commit -m "third" --secret
478 513 $ hg tag --local secret
479 514 $ hg checkout root
480 515 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
481 516 $ printf "four\n" > foo.whole
482 517 $ hg commit -m "fourth"
483 518 created new head
484 519 $ printf "uncommitted\n" > foo.whole
485 520
486 521 $ hg log --graph --template '{rev} {desc} {phase}\n'
487 522 @ 3 fourth draft
488 523 |
489 524 | o 2 third secret
490 525 | |
491 526 | o 1 second draft
492 527 |/
493 528 o 0 first public
494 529
495 530
496 531 $ hg fix --all
497 532 saved backup bundle to * (glob)
498 533
499 534 $ hg log --graph --template '{rev} {desc} {phase}\n'
500 535 @ 3 fourth draft
501 536 |
502 537 | o 2 third secret
503 538 | |
504 539 | o 1 second draft
505 540 |/
506 541 o 0 first public
507 542
508 543 $ hg cat -r 0 foo.whole
509 544 one
510 545 $ hg cat -r 1 foo.whole
511 546 TWO
512 547 $ hg cat -r 2 foo.whole
513 548 THREE
514 549 $ hg cat -r 3 foo.whole
515 550 FOUR
516 551 $ cat foo.whole
517 552 UNCOMMITTED
518 553 #endif
519 554
520 555 $ cd ..
521 556
General Comments 0
You need to be logged in to leave comments. Login now