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