##// END OF EJS Templates
update: add some tests for the status quo of morestatus on update conflicts...
Rodrigo Damazio Bovendorp -
r44336:5709a999 default
parent child Browse files
Show More
@@ -1,599 +1,645 b''
1 $ cat >> $HGRCPATH <<EOF
2 > [commands]
3 > status.verbose=1
4 > EOF
5
1 6 # Construct the following history tree:
2 7 #
3 8 # @ 5:e1bb631146ca b1
4 9 # |
5 10 # o 4:a4fdb3b883c4 0:b608b9236435 b1
6 11 # |
7 12 # | o 3:4b57d2520816 1:44592833ba9f
8 13 # | |
9 14 # | | o 2:063f31070f65
10 15 # | |/
11 16 # | o 1:44592833ba9f
12 17 # |/
13 18 # o 0:b608b9236435
14 19
15 20 $ mkdir b1
16 21 $ cd b1
17 22 $ hg init
18 23 $ echo foo > foo
19 24 $ echo zero > a
20 25 $ hg init sub
21 26 $ echo suba > sub/suba
22 27 $ hg --cwd sub ci -Am addsuba
23 28 adding suba
24 29 $ echo 'sub = sub' > .hgsub
25 30 $ hg ci -qAm0
26 31 $ echo one > a ; hg ci -m1
27 32 $ echo two > a ; hg ci -m2
28 33 $ hg up -q 1
29 34 $ echo three > a ; hg ci -qm3
30 35 $ hg up -q 0
31 36 $ hg branch -q b1
32 37 $ echo four > a ; hg ci -qm4
33 38 $ echo five > a ; hg ci -qm5
34 39
35 40 Initial repo state:
36 41
37 42 $ hg log -G --template '{rev}:{node|short} {parents} {branches}\n'
38 43 @ 5:ff252e8273df b1
39 44 |
40 45 o 4:d047485b3896 0:60829823a42a b1
41 46 |
42 47 | o 3:6efa171f091b 1:0786582aa4b1
43 48 | |
44 49 | | o 2:bd10386d478c
45 50 | |/
46 51 | o 1:0786582aa4b1
47 52 |/
48 53 o 0:60829823a42a
49 54
50 55
51 56 Make sure update doesn't assume b1 is a repository if invoked from outside:
52 57
53 58 $ cd ..
54 59 $ hg update b1
55 60 abort: no repository found in '$TESTTMP' (.hg not found)!
56 61 [255]
57 62 $ cd b1
58 63
59 64 Test helper functions:
60 65
61 66 $ revtest () {
62 67 > msg=$1
63 68 > dirtyflag=$2 # 'clean', 'dirty' or 'dirtysub'
64 69 > startrev=$3
65 70 > targetrev=$4
66 71 > opt=$5
67 72 > hg up -qC $startrev
68 73 > test $dirtyflag = dirty && echo dirty > foo
69 74 > test $dirtyflag = dirtysub && echo dirty > sub/suba
70 75 > hg up $opt $targetrev
71 76 > hg parent --template 'parent={rev}\n'
72 77 > hg stat -S
73 78 > }
74 79
75 80 $ norevtest () {
76 81 > msg=$1
77 82 > dirtyflag=$2 # 'clean', 'dirty' or 'dirtysub'
78 83 > startrev=$3
79 84 > opt=$4
80 85 > hg up -qC $startrev
81 86 > test $dirtyflag = dirty && echo dirty > foo
82 87 > test $dirtyflag = dirtysub && echo dirty > sub/suba
83 88 > hg up $opt
84 89 > hg parent --template 'parent={rev}\n'
85 90 > hg stat -S
86 91 > }
87 92
88 93 Test cases are documented in a table in the update function of merge.py.
89 94 Cases are run as shown in that table, row by row.
90 95
91 96 $ norevtest 'none clean linear' clean 4
92 97 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
93 98 parent=5
94 99
95 100 $ norevtest 'none clean same' clean 2
96 101 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
97 102 updated to "bd10386d478c: 2"
98 103 1 other heads for branch "default"
99 104 parent=2
100 105
101 106
102 107 $ revtest 'none clean linear' clean 1 2
103 108 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
104 109 parent=2
105 110
106 111 $ revtest 'none clean same' clean 2 3
107 112 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
108 113 parent=3
109 114
110 115 $ revtest 'none clean cross' clean 3 4
111 116 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
112 117 parent=4
113 118
114 119
115 120 $ revtest 'none dirty linear' dirty 1 2
116 121 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
117 122 parent=2
118 123 M foo
119 124
120 125 $ revtest 'none dirtysub linear' dirtysub 1 2
121 126 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 127 parent=2
123 128 M sub/suba
124 129
125 130 $ revtest 'none dirty same' dirty 2 3
126 131 abort: uncommitted changes
127 132 (commit or update --clean to discard changes)
128 133 parent=2
129 134 M foo
130 135
131 136 $ revtest 'none dirtysub same' dirtysub 2 3
132 137 abort: uncommitted changes
133 138 (commit or update --clean to discard changes)
134 139 parent=2
135 140 M sub/suba
136 141
137 142 $ revtest 'none dirty cross' dirty 3 4
138 143 abort: uncommitted changes
139 144 (commit or update --clean to discard changes)
140 145 parent=3
141 146 M foo
142 147
143 148 $ norevtest 'none dirty cross' dirty 2
144 149 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
145 150 updated to "bd10386d478c: 2"
146 151 1 other heads for branch "default"
147 152 parent=2
148 153 M foo
149 154
150 155 $ revtest 'none dirtysub cross' dirtysub 3 4
151 156 abort: uncommitted changes
152 157 (commit or update --clean to discard changes)
153 158 parent=3
154 159 M sub/suba
155 160
156 161 $ revtest '-C dirty linear' dirty 1 2 -C
157 162 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
158 163 parent=2
159 164
160 165 $ revtest '-c dirty linear' dirty 1 2 -c
161 166 abort: uncommitted changes
162 167 parent=1
163 168 M foo
164 169
165 170 $ revtest '-m dirty linear' dirty 1 2 -m
166 171 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
167 172 parent=2
168 173 M foo
169 174
170 175 $ revtest '-m dirty cross' dirty 3 4 -m
171 176 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
172 177 parent=4
173 178 M foo
174 179
175 180 $ revtest '-c dirtysub linear' dirtysub 1 2 -c
176 181 abort: uncommitted changes in subrepository "sub"
177 182 parent=1
178 183 M sub/suba
179 184
180 185 $ norevtest '-c clean same' clean 2 -c
181 186 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
182 187 updated to "bd10386d478c: 2"
183 188 1 other heads for branch "default"
184 189 parent=2
185 190
186 191 $ revtest '-cC dirty linear' dirty 1 2 -cC
187 192 abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
188 193 parent=1
189 194 M foo
190 195
191 196 $ revtest '-mc dirty linear' dirty 1 2 -mc
192 197 abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
193 198 parent=1
194 199 M foo
195 200
196 201 $ revtest '-mC dirty linear' dirty 1 2 -mC
197 202 abort: can only specify one of -C/--clean, -c/--check, or -m/--merge
198 203 parent=1
199 204 M foo
200 205
201 206 $ echo '[commands]' >> .hg/hgrc
202 207 $ echo 'update.check = abort' >> .hg/hgrc
203 208
204 209 $ revtest 'none dirty linear' dirty 1 2
205 210 abort: uncommitted changes
206 211 parent=1
207 212 M foo
208 213
209 214 $ revtest 'none dirty linear' dirty 1 2 -c
210 215 abort: uncommitted changes
211 216 parent=1
212 217 M foo
213 218
214 219 $ revtest 'none dirty linear' dirty 1 2 -C
215 220 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
216 221 parent=2
217 222
218 223 $ echo 'update.check = none' >> .hg/hgrc
219 224
220 225 $ revtest 'none dirty cross' dirty 3 4
221 226 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
222 227 parent=4
223 228 M foo
224 229
225 230 $ revtest 'none dirty linear' dirty 1 2
226 231 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
227 232 parent=2
228 233 M foo
229 234
230 235 $ revtest 'none dirty linear' dirty 1 2 -c
231 236 abort: uncommitted changes
232 237 parent=1
233 238 M foo
234 239
235 240 $ revtest 'none dirty linear' dirty 1 2 -C
236 241 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
237 242 parent=2
238 243
239 244 $ hg co -qC 3
240 245 $ echo dirty >> a
241 246 $ hg co --tool :merge3 4
242 247 merging a
243 248 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
244 249 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
245 250 use 'hg resolve' to retry unresolved file merges
246 251 [1]
247 252 $ hg st
248 253 M a
249 254 ? a.orig
250 255 $ cat a
251 256 <<<<<<< working copy: 6efa171f091b - test: 3
252 257 three
253 258 dirty
254 259 ||||||| base
255 260 three
256 261 =======
257 262 four
258 263 >>>>>>> destination: d047485b3896 b1 - test: 4
259 264 $ rm a.orig
260 265
261 266 $ echo 'update.check = noconflict' >> .hg/hgrc
262 267
263 268 $ revtest 'none dirty cross' dirty 3 4
264 269 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
265 270 parent=4
266 271 M foo
267 272
268 273 $ revtest 'none dirty linear' dirty 1 2
269 274 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
270 275 parent=2
271 276 M foo
272 277
273 278 $ revtest 'none dirty linear' dirty 1 2 -c
274 279 abort: uncommitted changes
275 280 parent=1
276 281 M foo
277 282
278 283 $ revtest 'none dirty linear' dirty 1 2 -C
279 284 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
280 285 parent=2
281 286
282 287 Locally added file is allowed
283 288 $ hg up -qC 3
284 289 $ echo a > bar
285 290 $ hg add bar
286 291 $ hg up -q 4
287 292 $ hg st
288 293 A bar
289 294 $ hg forget bar
290 295 $ rm bar
291 296
292 297 Locally removed file is allowed
293 298 $ hg up -qC 3
294 299 $ hg rm foo
295 300 $ hg up -q 4
296 301
297 302 File conflict is not allowed
298 303 $ hg up -qC 3
299 304 $ echo dirty >> a
300 305 $ hg up -q 4
301 306 abort: conflicting changes
302 307 (commit or update --clean to discard changes)
303 308 [255]
304 309 $ hg up -m 4
305 310 merging a
306 311 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
307 312 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
308 313 use 'hg resolve' to retry unresolved file merges
309 314 [1]
310 315 $ rm a.orig
316 $ hg status
317 M a
318 $ hg resolve -l
319 U a
311 320
312 321 Change/delete conflict is not allowed
313 322 $ hg up -qC 3
314 323 $ hg rm foo
315 324 $ hg up -q 4
316 325
317 326 Uses default value of "linear" when value is misspelled
318 327 $ echo 'update.check = linyar' >> .hg/hgrc
319 328
320 329 $ revtest 'dirty cross' dirty 3 4
321 330 abort: uncommitted changes
322 331 (commit or update --clean to discard changes)
323 332 parent=3
324 333 M foo
325 334
326 335 Setup for later tests
327 336 $ revtest 'none dirty linear' dirty 1 2 -c
328 337 abort: uncommitted changes
329 338 parent=1
330 339 M foo
331 340
332 341 $ cd ..
333 342
334 343 Test updating to null revision
335 344
336 345 $ hg init null-repo
337 346 $ cd null-repo
338 347 $ echo a > a
339 348 $ hg add a
340 349 $ hg ci -m a
341 350 $ hg up -qC 0
342 351 $ echo b > b
343 352 $ hg add b
344 353 $ hg up null
345 354 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
346 355 $ hg st
347 356 A b
348 357 $ hg up -q 0
349 358 $ hg st
350 359 A b
351 360 $ hg up -qC null
352 361 $ hg st
353 362 ? b
354 363 $ cd ..
355 364
356 365 Test updating with closed head
357 366 ---------------------------------------------------------------------
358 367
359 368 $ hg clone -U -q b1 closed-heads
360 369 $ cd closed-heads
361 370
362 371 Test updating if at least one non-closed branch head exists
363 372
364 373 if on the closed branch head:
365 374 - update to "."
366 375 - "updated to a closed branch head ...." message is displayed
367 376 - "N other heads for ...." message is displayed
368 377
369 378 $ hg update -q -C 3
370 379 $ hg commit --close-branch -m 6
371 380 $ norevtest "on closed branch head" clean 6
372 381 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
373 382 no open descendant heads on branch "default", updating to a closed head
374 383 (committing will reopen the head, use 'hg heads .' to see 1 other heads)
375 384 parent=6
376 385
377 386 if descendant non-closed branch head exists, and it is only one branch head:
378 387 - update to it, even if its revision is less than closed one
379 388 - "N other heads for ...." message isn't displayed
380 389
381 390 $ norevtest "non-closed 2 should be chosen" clean 1
382 391 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
383 392 parent=2
384 393
385 394 if all descendant branch heads are closed, but there is another branch head:
386 395 - update to the tipmost descendant head
387 396 - "updated to a closed branch head ...." message is displayed
388 397 - "N other heads for ...." message is displayed
389 398
390 399 $ norevtest "all descendant branch heads are closed" clean 3
391 400 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
392 401 no open descendant heads on branch "default", updating to a closed head
393 402 (committing will reopen the head, use 'hg heads .' to see 1 other heads)
394 403 parent=6
395 404
396 405 Test updating if all branch heads are closed
397 406
398 407 if on the closed branch head:
399 408 - update to "."
400 409 - "updated to a closed branch head ...." message is displayed
401 410 - "all heads of branch ...." message is displayed
402 411
403 412 $ hg update -q -C 2
404 413 $ hg commit --close-branch -m 7
405 414 $ norevtest "all heads of branch default are closed" clean 6
406 415 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
407 416 no open descendant heads on branch "default", updating to a closed head
408 417 (committing will reopen branch "default")
409 418 parent=6
410 419
411 420 if not on the closed branch head:
412 421 - update to the tipmost descendant (closed) head
413 422 - "updated to a closed branch head ...." message is displayed
414 423 - "all heads of branch ...." message is displayed
415 424
416 425 $ norevtest "all heads of branch default are closed" clean 1
417 426 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
418 427 no open descendant heads on branch "default", updating to a closed head
419 428 (committing will reopen branch "default")
420 429 parent=7
421 430
422 431 $ cd ..
423 432
424 433 Test updating if "default" branch doesn't exist and no revision is
425 434 checked out (= "default" is used as current branch)
426 435
427 436 $ hg init no-default-branch
428 437 $ cd no-default-branch
429 438
430 439 $ hg branch foobar
431 440 marked working directory as branch foobar
432 441 (branches are permanent and global, did you want a bookmark?)
433 442 $ echo a > a
434 443 $ hg commit -m "#0" -A
435 444 adding a
436 445 $ echo 1 >> a
437 446 $ hg commit -m "#1"
438 447 $ hg update -q 0
439 448 $ echo 3 >> a
440 449 $ hg commit -m "#2"
441 450 created new head
442 451 $ hg commit --close-branch -m "#3"
443 452
444 453 if there is at least one non-closed branch head:
445 454 - update to the tipmost branch head
446 455
447 456 $ norevtest "non-closed 1 should be chosen" clean null
448 457 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
449 458 parent=1
450 459
451 460 if all branch heads are closed
452 461 - update to "tip"
453 462 - "updated to a closed branch head ...." message is displayed
454 463 - "all heads for branch "XXXX" are closed" message is displayed
455 464
456 465 $ hg update -q -C 1
457 466 $ hg commit --close-branch -m "#4"
458 467
459 468 $ norevtest "all branches are closed" clean null
460 469 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
461 470 no open descendant heads on branch "foobar", updating to a closed head
462 471 (committing will reopen branch "foobar")
463 472 parent=4
464 473
465 474 $ cd ../b1
466 475
467 476 Test obsolescence behavior
468 477 ---------------------------------------------------------------------
469 478
470 479 successors should be taken in account when checking head destination
471 480
472 481 $ cat << EOF >> $HGRCPATH
473 482 > [ui]
474 483 > logtemplate={rev}:{node|short} {desc|firstline}
475 484 > [experimental]
476 485 > evolution.createmarkers=True
477 486 > EOF
478 487
479 488 Test no-argument update to a successor of an obsoleted changeset
480 489
481 490 $ hg log -G
482 491 o 5:ff252e8273df 5
483 492 |
484 493 o 4:d047485b3896 4
485 494 |
486 495 | o 3:6efa171f091b 3
487 496 | |
488 497 | | o 2:bd10386d478c 2
489 498 | |/
490 499 | @ 1:0786582aa4b1 1
491 500 |/
492 501 o 0:60829823a42a 0
493 502
494 503 $ hg book bm -r 3
495 504 $ hg status
496 505 M foo
497 506
498 507 We add simple obsolescence marker between 3 and 4 (indirect successors)
499 508
500 509 $ hg id --debug -i -r 3
501 510 6efa171f091b00a3c35edc15d48c52a498929953
502 511 $ hg id --debug -i -r 4
503 512 d047485b3896813b2a624e86201983520f003206
504 513 $ hg debugobsolete 6efa171f091b00a3c35edc15d48c52a498929953 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
505 514 1 new obsolescence markers
506 515 obsoleted 1 changesets
507 516 $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa d047485b3896813b2a624e86201983520f003206
508 517 1 new obsolescence markers
509 518
510 519 Test that 5 is detected as a valid destination from 3 and also accepts moving
511 520 the bookmark (issue4015)
512 521
513 522 $ hg up --quiet --hidden 3
514 523 $ hg up 5
515 524 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
516 525 $ hg book bm
517 526 moving bookmark 'bm' forward from 6efa171f091b
518 527 $ hg bookmarks
519 528 * bm 5:ff252e8273df
520 529
521 530 Test that we abort before we warn about the hidden commit if the working
522 531 directory is dirty
523 532 $ echo conflict > a
524 533 $ hg up --hidden 3
525 534 abort: uncommitted changes
526 535 (commit or update --clean to discard changes)
527 536 [255]
528 537
529 538 Test that we still warn also when there are conflicts
530 539 $ hg up -m --hidden 3
531 540 merging a
532 541 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
533 542 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
534 543 use 'hg resolve' to retry unresolved file merges
535 544 (leaving bookmark bm)
536 545 updated to hidden changeset 6efa171f091b
537 546 (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
538 547 [1]
548
549 Test that statuses are reported properly before and after merge resolution.
550 $ rm a.orig
551 $ hg resolve -l
552 U a
553 $ hg status
554 M a
555 M foo
556
539 557 $ hg revert -r . a
558
559 $ rm a.orig
560 $ hg resolve -l
561 U a
562 $ hg status
563 M foo
564 $ hg status -Tjson
565 [
566 {
567 "itemtype": "file",
568 "path": "foo",
569 "status": "M"
570 }
571 ]
572
540 573 $ hg resolve -m
541 574 (no more unresolved files)
542 575
576 $ hg resolve -l
577 R a
578 $ hg status
579 M foo
580 $ hg status -Tjson
581 [
582 {
583 "itemtype": "file",
584 "path": "foo",
585 "status": "M"
586 }
587 ]
588
543 589 Test that 4 is detected as the no-argument destination from 3 and also moves
544 590 the bookmark with it
545 591 $ hg up --quiet 0 # we should be able to update to 3 directly
546 592 $ hg up --quiet --hidden 3 # but not implemented yet.
547 593 updated to hidden changeset 6efa171f091b
548 594 (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
549 595 $ hg book -f bm
550 596 $ hg up
551 597 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
552 598 updating bookmark bm
553 599 $ hg book
554 600 * bm 4:d047485b3896
555 601
556 602 Test that 5 is detected as a valid destination from 1
557 603 $ hg up --quiet 0 # we should be able to update to 3 directly
558 604 $ hg up --quiet --hidden 3 # but not implemented yet.
559 605 updated to hidden changeset 6efa171f091b
560 606 (hidden revision '6efa171f091b' was rewritten as: d047485b3896)
561 607 $ hg up 5
562 608 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
563 609
564 610 Test that 5 is not detected as a valid destination from 2
565 611 $ hg up --quiet 0
566 612 $ hg up --quiet 2
567 613 $ hg up 5
568 614 abort: uncommitted changes
569 615 (commit or update --clean to discard changes)
570 616 [255]
571 617
572 618 Test that we don't crash when updating from a pruned changeset (i.e. has no
573 619 successors). Behavior should probably be that we update to the first
574 620 non-obsolete parent but that will be decided later.
575 621 $ hg id --debug -r 2
576 622 bd10386d478cd5a9faf2e604114c8e6da62d3889
577 623 $ hg up --quiet 0
578 624 $ hg up --quiet 2
579 625 $ hg debugobsolete bd10386d478cd5a9faf2e604114c8e6da62d3889
580 626 1 new obsolescence markers
581 627 obsoleted 1 changesets
582 628 $ hg up
583 629 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
584 630
585 631 Test experimental revset support
586 632
587 633 $ hg log -r '_destupdate()'
588 634 2:bd10386d478c 2 (no-eol)
589 635
590 636 Test that boolean flags allow --no-flag specification to override [defaults]
591 637 $ cat >> $HGRCPATH <<EOF
592 638 > [defaults]
593 639 > update = --check
594 640 > EOF
595 641 $ hg co 2
596 642 abort: uncommitted changes
597 643 [255]
598 644 $ hg co --no-check 2
599 645 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now