##// END OF EJS Templates
shelve: add test for Shelf.changed_files
Jason R. Coombs -
r50482:8a800502 default
parent child Browse files
Show More
@@ -1,1630 +1,1660 b''
1 1 #testcases stripbased phasebased
2 2 #testcases dirstate-v1 dirstate-v2
3 3
4 4 #if dirstate-v2
5 5 $ cat >> $HGRCPATH << EOF
6 6 > [format]
7 7 > use-dirstate-v2=1
8 8 > [storage]
9 9 > dirstate-v2.slow-path=allow
10 10 > EOF
11 11 #endif
12 12
13 13 $ cat <<EOF >> $HGRCPATH
14 14 > [extensions]
15 15 > mq =
16 16 > [defaults]
17 17 > diff = --nodates --git
18 18 > qnew = --date '0 0'
19 19 > [shelve]
20 20 > maxbackups = 2
21 21 > EOF
22 22
23 23 #if phasebased
24 24
25 25 $ cat <<EOF >> $HGRCPATH
26 26 > [format]
27 27 > use-internal-phase = yes
28 28 > EOF
29 29
30 30 #endif
31 31
32 32 $ hg init repo
33 33 $ cd repo
34 34 $ mkdir a b
35 35 $ echo a > a/a
36 36 $ echo b > b/b
37 37 $ echo c > c
38 38 $ echo d > d
39 39 $ echo x > x
40 40 $ hg addremove -q
41 41
42 42 shelve has a help message
43 43 $ hg shelve -h
44 44 hg shelve [OPTION]... [FILE]...
45 45
46 46 save and set aside changes from the working directory
47 47
48 48 Shelving takes files that "hg status" reports as not clean, saves the
49 49 modifications to a bundle (a shelved change), and reverts the files so
50 50 that their state in the working directory becomes clean.
51 51
52 52 To restore these changes to the working directory, using "hg unshelve";
53 53 this will work even if you switch to a different commit.
54 54
55 55 When no files are specified, "hg shelve" saves all not-clean files. If
56 56 specific files or directories are named, only changes to those files are
57 57 shelved.
58 58
59 59 In bare shelve (when no files are specified, without interactive, include
60 60 and exclude option), shelving remembers information if the working
61 61 directory was on newly created branch, in other words working directory
62 62 was on different branch than its first parent. In this situation
63 63 unshelving restores branch information to the working directory.
64 64
65 65 Each shelved change has a name that makes it easier to find later. The
66 66 name of a shelved change defaults to being based on the active bookmark,
67 67 or if there is no active bookmark, the current named branch. To specify a
68 68 different name, use "--name".
69 69
70 70 To see a list of existing shelved changes, use the "--list" option. For
71 71 each shelved change, this will print its name, age, and description; use "
72 72 --patch" or "--stat" for more details.
73 73
74 74 To delete specific shelved changes, use "--delete". To delete all shelved
75 75 changes, use "--cleanup".
76 76
77 77 options ([+] can be repeated):
78 78
79 79 -A --addremove mark new/missing files as added/removed before
80 80 shelving
81 81 -u --unknown store unknown files in the shelve
82 82 --cleanup delete all shelved changes
83 83 --date DATE shelve with the specified commit date
84 84 -d --delete delete the named shelved change(s)
85 85 -e --edit invoke editor on commit messages
86 86 -k --keep shelve, but keep changes in the working directory
87 87 -l --list list current shelves
88 88 -m --message TEXT use text as shelve message
89 89 -n --name NAME use the given name for the shelved commit
90 90 -p --patch output patches for changes (provide the names of the
91 91 shelved changes as positional arguments)
92 92 -i --interactive interactive mode
93 93 --stat output diffstat-style summary of changes (provide
94 94 the names of the shelved changes as positional
95 95 arguments)
96 96 -I --include PATTERN [+] include names matching the given patterns
97 97 -X --exclude PATTERN [+] exclude names matching the given patterns
98 98 --mq operate on patch repository
99 99
100 100 (some details hidden, use --verbose to show complete help)
101 101
102 102 shelving in an empty repo should be possible
103 103 (this tests also that editor is not invoked, if '--edit' is not
104 104 specified)
105 105
106 106 $ HGEDITOR=cat hg shelve
107 107 shelved as default
108 108 0 files updated, 0 files merged, 5 files removed, 0 files unresolved
109 109
110 110 $ hg unshelve
111 111 unshelving change 'default'
112 112
113 113 $ hg commit -q -m 'initial commit'
114 114
115 115 $ hg shelve
116 116 nothing changed
117 117 [1]
118 118
119 119 make sure shelve files were backed up
120 120
121 121 $ ls .hg/shelve-backup
122 122 default.hg
123 123 default.patch
124 124 default.shelve
125 125
126 126 checks to make sure we dont create a directory or
127 127 hidden file while choosing a new shelve name
128 128
129 129 when we are given a name
130 130
131 131 $ hg shelve -n foo/bar
132 132 abort: shelved change names can not contain slashes
133 133 [255]
134 134 $ hg shelve -n .baz
135 135 abort: shelved change names can not start with '.'
136 136 [255]
137 137 $ hg shelve -n foo\\bar
138 138 abort: shelved change names can not contain slashes
139 139 [255]
140 140
141 141 when shelve has to choose itself
142 142
143 143 $ hg branch x/y -q
144 144 $ hg commit -q -m "Branch commit 0"
145 145 $ hg shelve
146 146 nothing changed
147 147 [1]
148 148 $ hg branch .x -q
149 149 $ hg commit -q -m "Branch commit 1"
150 150 $ hg shelve
151 151 nothing changed
152 152 [1]
153 153 $ hg branch x\\y -q
154 154 $ hg commit -q -m "Branch commit 2"
155 155 $ hg shelve
156 156 nothing changed
157 157 [1]
158 158
159 159 cleaning the branches made for name checking tests
160 160
161 161 $ hg up default -q
162 162 $ hg strip e9177275307e+6a6d231f43d+882bae7c62c2 -q
163 163
164 164 create an mq patch - shelving should work fine with a patch applied
165 165
166 166 $ echo n > n
167 167 $ hg add n
168 168 $ hg commit n -m second
169 169 $ hg qnew second.patch
170 170
171 171 shelve a change that we will delete later
172 172
173 173 $ echo a >> a/a
174 174 $ hg shelve
175 175 shelved as default
176 176 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
177 177
178 178 set up some more complex changes to shelve
179 179
180 180 $ echo a >> a/a
181 181 $ hg mv b b.rename
182 182 moving b/b to b.rename/b
183 183 $ hg cp c c.copy
184 184 $ hg mv d ghost
185 185 $ rm ghost
186 186 $ hg status -C
187 187 M a/a
188 188 A b.rename/b
189 189 b/b
190 190 A c.copy
191 191 c
192 192 R b/b
193 193 R d
194 194 ! ghost
195 195 d
196 196
197 197 the common case - no options or filenames
198 198
199 199 $ hg shelve
200 200 shelved as default-01
201 201 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
202 202 $ hg status -C
203 203
204 204 ensure that our shelved changes exist
205 205
206 206 $ hg shelve -l
207 207 default-01 (*)* changes to: [mq]: second.patch (glob)
208 208 default (*)* changes to: [mq]: second.patch (glob)
209 209
210 210 $ hg shelve -l -p default
211 211 default (*)* changes to: [mq]: second.patch (glob)
212 212
213 213 diff --git a/a/a b/a/a
214 214 --- a/a/a
215 215 +++ b/a/a
216 216 @@ -1,1 +1,2 @@
217 217 a
218 218 +a
219 219
220 220 $ hg shelve --list --addremove
221 221 abort: options '--list' and '--addremove' may not be used together
222 222 [10]
223 223
224 224 delete our older shelved change
225 225
226 226 $ hg shelve -d default
227 227 $ hg qfinish -a -q
228 228
229 229 ensure shelve backups aren't overwritten
230 230
231 231 $ ls .hg/shelve-backup/
232 232 default-1.hg
233 233 default-1.patch
234 234 default-1.shelve
235 235 default.hg
236 236 default.patch
237 237 default.shelve
238 238
239 239 local edits should not prevent a shelved change from applying
240 240
241 241 $ printf "z\na\n" > a/a
242 242 $ hg unshelve --keep
243 243 unshelving change 'default-01'
244 244 temporarily committing pending changes (restore with 'hg unshelve --abort')
245 245 rebasing shelved changes
246 246 merging a/a
247 247
248 248 $ hg revert --all -q
249 249 $ rm a/a.orig b.rename/b c.copy
250 250
251 251 apply it and make sure our state is as expected
252 252
253 253 (this also tests that same timestamp prevents backups from being
254 254 removed, even though there are more than 'maxbackups' backups)
255 255
256 256 $ f -t .hg/shelve-backup/default.shelve
257 257 .hg/shelve-backup/default.shelve: file
258 258 $ touch -t 200001010000 .hg/shelve-backup/default.shelve
259 259 $ f -t .hg/shelve-backup/default-1.shelve
260 260 .hg/shelve-backup/default-1.shelve: file
261 261 $ touch -t 200001010000 .hg/shelve-backup/default-1.shelve
262 262
263 263 $ hg unshelve
264 264 unshelving change 'default-01'
265 265 $ hg status -C
266 266 M a/a
267 267 A b.rename/b
268 268 b/b
269 269 A c.copy
270 270 c
271 271 R b/b
272 272 R d
273 273 $ hg shelve -l
274 274
275 275 (both of default.hg and default-1.hg should be still kept, because it
276 276 is difficult to decide actual order of them from same timestamp)
277 277
278 278 $ ls .hg/shelve-backup/
279 279 default-01.hg
280 280 default-01.patch
281 281 default-01.shelve
282 282 default-1.hg
283 283 default-1.patch
284 284 default-1.shelve
285 285 default.hg
286 286 default.patch
287 287 default.shelve
288 288
289 289 $ hg unshelve
290 290 abort: no shelved changes to apply!
291 291 [20]
292 292 $ hg unshelve foo
293 293 abort: shelved change 'foo' not found
294 294 [10]
295 295
296 296 named shelves, specific filenames, and "commit messages" should all work
297 297 (this tests also that editor is invoked, if '--edit' is specified)
298 298
299 299 $ hg status -C
300 300 M a/a
301 301 A b.rename/b
302 302 b/b
303 303 A c.copy
304 304 c
305 305 R b/b
306 306 R d
307 307 $ HGEDITOR=cat hg shelve -q -n wibble -m wat -e a
308 308 wat
309 309
310 310
311 311 HG: Enter commit message. Lines beginning with 'HG:' are removed.
312 312 HG: Leave message empty to abort commit.
313 313 HG: --
314 314 HG: user: shelve@localhost
315 315 HG: branch 'default'
316 316 HG: changed a/a
317 317
318 318 expect "a" to no longer be present, but status otherwise unchanged
319 319
320 320 $ hg status -C
321 321 A b.rename/b
322 322 b/b
323 323 A c.copy
324 324 c
325 325 R b/b
326 326 R d
327 327 $ hg shelve -l --stat
328 328 wibble (*) wat (glob)
329 329 a/a | 1 +
330 330 1 files changed, 1 insertions(+), 0 deletions(-)
331 331
332 332 and now "a/a" should reappear
333 333
334 334 $ cd a
335 335 $ hg unshelve -q wibble
336 336 $ cd ..
337 337 $ hg status -C
338 338 M a/a
339 339 A b.rename/b
340 340 b/b
341 341 A c.copy
342 342 c
343 343 R b/b
344 344 R d
345 345
346 346 ensure old shelve backups are being deleted automatically
347 347
348 348 $ ls .hg/shelve-backup/
349 349 default-01.hg
350 350 default-01.patch
351 351 default-01.shelve
352 352 wibble.hg
353 353 wibble.patch
354 354 wibble.shelve
355 355
356 356 cause unshelving to result in a merge with 'a' conflicting
357 357
358 358 $ hg shelve -q
359 359 $ echo c>>a/a
360 360 $ hg commit -m second
361 361 $ hg tip --template '{files}\n'
362 362 a/a
363 363
364 364 add an unrelated change that should be preserved
365 365
366 366 $ mkdir foo
367 367 $ echo foo > foo/foo
368 368 $ hg add foo/foo
369 369
370 370 force a conflicted merge to occur
371 371
372 372 $ hg unshelve
373 373 unshelving change 'default'
374 374 temporarily committing pending changes (restore with 'hg unshelve --abort')
375 375 rebasing shelved changes
376 376 merging a/a
377 377 warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark')
378 378 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
379 379 [240]
380 380 $ hg status -v
381 381 M a/a
382 382 M b.rename/b
383 383 M c.copy
384 384 R b/b
385 385 R d
386 386 ? a/a.orig
387 387 # The repository is in an unfinished *unshelve* state.
388 388
389 389 # Unresolved merge conflicts:
390 390 #
391 391 # a/a
392 392 #
393 393 # To mark files as resolved: hg resolve --mark FILE
394 394
395 395 # To continue: hg unshelve --continue
396 396 # To abort: hg unshelve --abort
397 397
398 398
399 399 ensure that we have a merge with unresolved conflicts
400 400
401 401 #if phasebased
402 402 $ hg heads -q --template '{rev}\n'
403 403 8
404 404 5
405 405 $ hg parents -q --template '{rev}\n'
406 406 8
407 407 5
408 408 #endif
409 409
410 410 #if stripbased
411 411 $ hg heads -q --template '{rev}\n'
412 412 5
413 413 4
414 414 $ hg parents -q --template '{rev}\n'
415 415 4
416 416 5
417 417 #endif
418 418
419 419 $ hg status
420 420 M a/a
421 421 M b.rename/b
422 422 M c.copy
423 423 R b/b
424 424 R d
425 425 ? a/a.orig
426 426 $ hg diff
427 427 diff --git a/a/a b/a/a
428 428 --- a/a/a
429 429 +++ b/a/a
430 430 @@ -1,2 +1,6 @@
431 431 a
432 432 +<<<<<<< working-copy: 2377350b6337 - shelve: pending changes temporary commit
433 433 c
434 434 +=======
435 435 +a
436 436 +>>>>>>> shelved change: 203c9f771d2b - shelve: changes to: [mq]: second.patch
437 437 diff --git a/b/b b/b.rename/b
438 438 rename from b/b
439 439 rename to b.rename/b
440 440 diff --git a/c b/c.copy
441 441 copy from c
442 442 copy to c.copy
443 443 diff --git a/d b/d
444 444 deleted file mode 100644
445 445 --- a/d
446 446 +++ /dev/null
447 447 @@ -1,1 +0,0 @@
448 448 -d
449 449 $ hg resolve -l
450 450 U a/a
451 451
452 452 $ hg shelve
453 453 abort: unshelve already in progress
454 454 (use 'hg unshelve --continue' or 'hg unshelve --abort')
455 455 [20]
456 456
457 457 abort the unshelve and be happy
458 458
459 459 $ hg status
460 460 M a/a
461 461 M b.rename/b
462 462 M c.copy
463 463 R b/b
464 464 R d
465 465 ? a/a.orig
466 466 $ hg unshelve -a
467 467 unshelve of 'default' aborted
468 468 $ hg heads -q
469 469 [37]:2e69b451d1ea (re)
470 470 $ hg parents
471 471 changeset: [37]:2e69b451d1ea (re)
472 472 tag: tip
473 473 parent: 3:509104101065 (?)
474 474 user: test
475 475 date: Thu Jan 01 00:00:00 1970 +0000
476 476 summary: second
477 477
478 478 $ hg resolve -l
479 479 $ hg status
480 480 A foo/foo
481 481 ? a/a.orig
482 482
483 483 try to continue with no unshelve underway
484 484
485 485 $ hg unshelve -c
486 486 abort: no unshelve in progress
487 487 [20]
488 488 $ hg status
489 489 A foo/foo
490 490 ? a/a.orig
491 491
492 492 redo the unshelve to get a conflict
493 493
494 494 $ hg unshelve -q
495 495 warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark')
496 496 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
497 497 [240]
498 498
499 499 attempt to continue
500 500
501 501 $ hg unshelve -c
502 502 abort: unresolved conflicts, can't continue
503 503 (see 'hg resolve', then 'hg unshelve --continue')
504 504 [255]
505 505
506 506 $ hg revert -r . a/a
507 507 $ hg resolve -m a/a
508 508 (no more unresolved files)
509 509 continue: hg unshelve --continue
510 510
511 511 $ hg commit -m 'commit while unshelve in progress'
512 512 abort: unshelve already in progress
513 513 (use 'hg unshelve --continue' or 'hg unshelve --abort')
514 514 [20]
515 515
516 516 $ hg graft --continue
517 517 abort: no graft in progress
518 518 (continue: hg unshelve --continue)
519 519 [20]
520 520 $ hg unshelve -c
521 521 unshelve of 'default' complete
522 522
523 523 ensure the repo is as we hope
524 524
525 525 $ hg parents
526 526 changeset: [37]:2e69b451d1ea (re)
527 527 tag: tip
528 528 parent: 3:509104101065 (?)
529 529 user: test
530 530 date: Thu Jan 01 00:00:00 1970 +0000
531 531 summary: second
532 532
533 533 $ hg heads -q
534 534 [37]:2e69b451d1ea (re)
535 535
536 536 $ hg status -C
537 537 A b.rename/b
538 538 b/b
539 539 A c.copy
540 540 c
541 541 A foo/foo
542 542 R b/b
543 543 R d
544 544 ? a/a.orig
545 545
546 546 there should be no shelves left
547 547
548 548 $ hg shelve -l
549 549
550 550 #if execbit
551 551
552 552 ensure that metadata-only changes are shelved
553 553
554 554 $ chmod +x a/a
555 555 $ hg shelve -q -n execbit a/a
556 556 $ hg status a/a
557 557 $ hg unshelve -q execbit
558 558 $ hg status a/a
559 559 M a/a
560 560 $ hg revert a/a
561 561
562 562 #else
563 563
564 564 Dummy shelve op, to keep rev numbers aligned
565 565
566 566 $ echo foo > a/a
567 567 $ hg shelve -q -n dummy a/a
568 568 $ hg unshelve -q dummy
569 569 $ hg revert a/a
570 570
571 571 #endif
572 572
573 573 #if symlink
574 574
575 575 $ rm a/a
576 576 $ ln -s foo a/a
577 577 $ hg shelve -q -n symlink a/a
578 578 $ hg status a/a
579 579 $ hg unshelve -q -n symlink
580 580 $ hg status a/a
581 581 M a/a
582 582 $ hg revert a/a
583 583
584 584 #else
585 585
586 586 Dummy shelve op, to keep rev numbers aligned
587 587
588 588 $ echo bar > a/a
589 589 $ hg shelve -q -n dummy a/a
590 590 $ hg unshelve -q dummy
591 591 $ hg revert a/a
592 592
593 593 #endif
594 594
595 595 set up another conflict between a commit and a shelved change
596 596
597 597 $ hg revert -q -C -a
598 598 $ rm a/a.orig b.rename/b c.copy
599 599 $ echo a >> a/a
600 600 $ hg shelve -q
601 601 $ echo x >> a/a
602 602 $ hg ci -m 'create conflict'
603 603 $ hg add foo/foo
604 604
605 605 if we resolve a conflict while unshelving, the unshelve should succeed
606 606
607 607 $ hg unshelve --tool :merge-other --keep
608 608 unshelving change 'default'
609 609 temporarily committing pending changes (restore with 'hg unshelve --abort')
610 610 rebasing shelved changes
611 611 merging a/a
612 612 $ hg parents -q
613 613 (4|13):33f7f61e6c5e (re)
614 614 $ hg shelve -l
615 615 default (*)* changes to: second (glob)
616 616 $ hg status
617 617 M a/a
618 618 A foo/foo
619 619 $ cat a/a
620 620 a
621 621 c
622 622 a
623 623 $ cat > a/a << EOF
624 624 > a
625 625 > c
626 626 > x
627 627 > EOF
628 628
629 629 $ HGMERGE=true hg unshelve
630 630 unshelving change 'default'
631 631 temporarily committing pending changes (restore with 'hg unshelve --abort')
632 632 rebasing shelved changes
633 633 merging a/a
634 634 note: unshelved changes already existed in the working copy
635 635 $ hg parents -q
636 636 (4|13):33f7f61e6c5e (re)
637 637 $ hg shelve -l
638 638 $ hg status
639 639 A foo/foo
640 640 $ cat a/a
641 641 a
642 642 c
643 643 x
644 644
645 645 test keep and cleanup
646 646
647 647 $ hg shelve
648 648 shelved as default
649 649 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
650 650 $ hg shelve --list
651 651 default (*)* changes to: create conflict (glob)
652 652 $ hg unshelve -k
653 653 unshelving change 'default'
654 654 $ hg shelve --list
655 655 default (*)* changes to: create conflict (glob)
656 656 $ hg shelve --cleanup
657 657 $ hg shelve --list
658 658
659 659 $ hg shelve --cleanup --delete
660 660 abort: options '--cleanup' and '--delete' may not be used together
661 661 [10]
662 662 $ hg shelve --cleanup --patch
663 663 abort: options '--cleanup' and '--patch' may not be used together
664 664 [10]
665 665 $ hg shelve --cleanup --message MESSAGE
666 666 abort: options '--cleanup' and '--message' may not be used together
667 667 [10]
668 668
669 669 test bookmarks
670 670
671 671 $ hg bookmark test
672 672 $ hg bookmark
673 673 \* test (4|13):33f7f61e6c5e (re)
674 674 $ hg shelve
675 675 shelved as test
676 676 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
677 677 $ hg bookmark
678 678 \* test (4|13):33f7f61e6c5e (re)
679 679 $ hg unshelve
680 680 unshelving change 'test'
681 681 $ hg bookmark
682 682 \* test (4|13):33f7f61e6c5e (re)
683 683
684 684 shelve should still work even if mq is disabled
685 685
686 686 $ hg --config extensions.mq=! shelve
687 687 shelved as test
688 688 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
689 689 $ hg --config extensions.mq=! shelve --list
690 690 test (*)* changes to: create conflict (glob)
691 691 $ hg bookmark
692 692 \* test (4|13):33f7f61e6c5e (re)
693 693 $ hg --config extensions.mq=! unshelve
694 694 unshelving change 'test'
695 695 $ hg bookmark
696 696 \* test (4|13):33f7f61e6c5e (re)
697 697
698 698 Recreate some conflict again
699 699
700 700 $ hg up -C -r 2e69b451d1ea
701 701 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
702 702 (leaving bookmark test)
703 703 $ echo y >> a/a
704 704 $ hg shelve
705 705 shelved as default
706 706 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
707 707 $ hg up test
708 708 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
709 709 (activating bookmark test)
710 710 $ hg bookmark
711 711 \* test (4|13):33f7f61e6c5e (re)
712 712 $ hg unshelve
713 713 unshelving change 'default'
714 714 rebasing shelved changes
715 715 merging a/a
716 716 warning: conflicts while merging a/a! (edit, then use 'hg resolve --mark')
717 717 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
718 718 [240]
719 719 $ hg bookmark
720 720 test (4|13):33f7f61e6c5e (re)
721 721
722 722 Test that resolving all conflicts in one direction (so that the rebase
723 723 is a no-op), works (issue4398)
724 724
725 725 $ hg revert -a -r .
726 726 reverting a/a
727 727 $ hg resolve -m a/a
728 728 (no more unresolved files)
729 729 continue: hg unshelve --continue
730 730 $ hg unshelve -c
731 731 note: unshelved changes already existed in the working copy
732 732 unshelve of 'default' complete
733 733 $ hg bookmark
734 734 \* test (4|13):33f7f61e6c5e (re)
735 735 $ hg diff
736 736 $ hg status
737 737 ? a/a.orig
738 738 ? foo/foo
739 739 $ hg summary
740 740 parent: (4|13):33f7f61e6c5e tip (re)
741 741 create conflict
742 742 branch: default
743 743 bookmarks: *test
744 744 commit: 2 unknown (clean)
745 745 update: (current)
746 746 phases: 5 draft
747 747
748 748 $ hg shelve --delete --stat
749 749 abort: options '--delete' and '--stat' may not be used together
750 750 [10]
751 751 $ hg shelve --delete --name NAME
752 752 abort: options '--delete' and '--name' may not be used together
753 753 [10]
754 754
755 755 Test interactive shelve
756 756 $ cat <<EOF >> $HGRCPATH
757 757 > [ui]
758 758 > interactive = true
759 759 > EOF
760 760 $ echo 'a' >> a/b
761 761 $ cat a/a >> a/b
762 762 $ echo 'x' >> a/b
763 763 $ mv a/b a/a
764 764 $ echo 'a' >> foo/foo
765 765 $ hg st
766 766 M a/a
767 767 ? a/a.orig
768 768 ? foo/foo
769 769 $ cat a/a
770 770 a
771 771 a
772 772 c
773 773 x
774 774 x
775 775 $ cat foo/foo
776 776 foo
777 777 a
778 778 $ hg shelve --interactive --config ui.interactive=false
779 779 abort: running non-interactively
780 780 [10]
781 781 $ hg shelve --interactive << EOF
782 782 > y
783 783 > y
784 784 > n
785 785 > EOF
786 786 diff --git a/a/a b/a/a
787 787 2 hunks, 2 lines changed
788 788 examine changes to 'a/a'?
789 789 (enter ? for help) [Ynesfdaq?] y
790 790
791 791 @@ -1,3 +1,4 @@
792 792 +a
793 793 a
794 794 c
795 795 x
796 796 record change 1/2 to 'a/a'?
797 797 (enter ? for help) [Ynesfdaq?] y
798 798
799 799 @@ -1,3 +2,4 @@
800 800 a
801 801 c
802 802 x
803 803 +x
804 804 record change 2/2 to 'a/a'?
805 805 (enter ? for help) [Ynesfdaq?] n
806 806
807 807 shelved as test
808 808 merging a/a
809 809 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
810 810 $ cat a/a
811 811 a
812 812 c
813 813 x
814 814 x
815 815 $ cat foo/foo
816 816 foo
817 817 a
818 818 $ hg st
819 819 M a/a
820 820 ? foo/foo
821 821 $ hg bookmark
822 822 \* test (4|13):33f7f61e6c5e (re)
823 823 there shouldn't be a merge state
824 824 $ hg resolve -l
825 825 $ hg unshelve
826 826 unshelving change 'test'
827 827 temporarily committing pending changes (restore with 'hg unshelve --abort')
828 828 rebasing shelved changes
829 829 merging a/a
830 830 $ hg bookmark
831 831 \* test (4|13):33f7f61e6c5e (re)
832 832 $ cat a/a
833 833 a
834 834 a
835 835 c
836 836 x
837 837 x
838 838
839 839 shelve --patch and shelve --stat should work with valid shelfnames
840 840
841 841 $ hg up --clean .
842 842 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
843 843 (leaving bookmark test)
844 844 $ hg shelve --list
845 845 $ echo 'patch a' > shelf-patch-a
846 846 $ hg add shelf-patch-a
847 847 $ hg shelve
848 848 shelved as default
849 849 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
850 850 $ echo 'patch b' > shelf-patch-b
851 851 $ hg add shelf-patch-b
852 852 $ hg shelve
853 853 shelved as default-01
854 854 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
855 855 $ hg shelve --patch default default-01
856 856 default-01 (*)* changes to: create conflict (glob)
857 857
858 858 diff --git a/shelf-patch-b b/shelf-patch-b
859 859 new file mode 100644
860 860 --- /dev/null
861 861 +++ b/shelf-patch-b
862 862 @@ -0,0 +1,1 @@
863 863 +patch b
864 864 default (*)* changes to: create conflict (glob)
865 865
866 866 diff --git a/shelf-patch-a b/shelf-patch-a
867 867 new file mode 100644
868 868 --- /dev/null
869 869 +++ b/shelf-patch-a
870 870 @@ -0,0 +1,1 @@
871 871 +patch a
872 872 $ hg shelve --stat default default-01
873 873 default-01 (*)* changes to: create conflict (glob)
874 874 shelf-patch-b | 1 +
875 875 1 files changed, 1 insertions(+), 0 deletions(-)
876 876 default (*)* changes to: create conflict (glob)
877 877 shelf-patch-a | 1 +
878 878 1 files changed, 1 insertions(+), 0 deletions(-)
879 879 $ hg shelve --patch default
880 880 default (*)* changes to: create conflict (glob)
881 881
882 882 diff --git a/shelf-patch-a b/shelf-patch-a
883 883 new file mode 100644
884 884 --- /dev/null
885 885 +++ b/shelf-patch-a
886 886 @@ -0,0 +1,1 @@
887 887 +patch a
888 888 $ hg shelve --stat default
889 889 default (*)* changes to: create conflict (glob)
890 890 shelf-patch-a | 1 +
891 891 1 files changed, 1 insertions(+), 0 deletions(-)
892 892 $ hg shelve --patch nonexistentshelf
893 893 abort: cannot find shelf nonexistentshelf
894 894 [255]
895 895 $ hg shelve --stat nonexistentshelf
896 896 abort: cannot find shelf nonexistentshelf
897 897 [255]
898 898 $ hg shelve --patch default nonexistentshelf
899 899 abort: cannot find shelf nonexistentshelf
900 900 [255]
901 901
902 902 when the user asks for a patch, we assume they want the most recent shelve if
903 903 they don't provide a shelve name
904 904
905 905 $ hg shelve --patch
906 906 default-01 (*)* changes to: create conflict (glob)
907 907
908 908 diff --git a/shelf-patch-b b/shelf-patch-b
909 909 new file mode 100644
910 910 --- /dev/null
911 911 +++ b/shelf-patch-b
912 912 @@ -0,0 +1,1 @@
913 913 +patch b
914 914
915 915 $ cd ..
916 916
917 917 Shelve from general delta repo uses bundle2 on disk
918 918 --------------------------------------------------
919 919
920 920 no general delta
921 921
922 922 $ hg clone --pull repo bundle1 --config format.usegeneraldelta=0
923 923 requesting all changes
924 924 adding changesets
925 925 adding manifests
926 926 adding file changes
927 927 added 5 changesets with 8 changes to 6 files
928 928 new changesets cc01e2b0c59f:33f7f61e6c5e
929 929 updating to branch default
930 930 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
931 931 $ cd bundle1
932 932 $ echo babar > jungle
933 933 $ hg add jungle
934 934 $ hg shelve
935 935 shelved as default
936 936 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
937 937 $ hg debugbundle .hg/shelved/*.hg
938 938 330882a04d2ce8487636b1fb292e5beea77fa1e3
939 939 $ cd ..
940 940
941 941 with general delta
942 942
943 943 $ hg clone --pull repo bundle2 --config format.usegeneraldelta=1
944 944 requesting all changes
945 945 adding changesets
946 946 adding manifests
947 947 adding file changes
948 948 added 5 changesets with 8 changes to 6 files
949 949 new changesets cc01e2b0c59f:33f7f61e6c5e
950 950 updating to branch default
951 951 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
952 952 $ cd bundle2
953 953 $ echo babar > jungle
954 954 $ hg add jungle
955 955 $ hg shelve
956 956 shelved as default
957 957 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
958 958 $ hg debugbundle .hg/shelved/*.hg
959 959 Stream params: {Compression: BZ}
960 960 changegroup -- {nbchanges: 1, version: 02} (mandatory: True)
961 961 330882a04d2ce8487636b1fb292e5beea77fa1e3
962 962
963 963 Test shelve --keep
964 964
965 965 $ hg unshelve
966 966 unshelving change 'default'
967 967 $ hg shelve --keep --list
968 968 abort: options '--list' and '--keep' may not be used together
969 969 [10]
970 970 $ hg shelve --keep --patch
971 971 abort: options '--patch' and '--keep' may not be used together
972 972 [10]
973 973 $ hg shelve --keep --delete
974 974 abort: options '--delete' and '--keep' may not be used together
975 975 [10]
976 976 $ hg shelve --keep
977 977 shelved as default
978 978 $ hg diff
979 979 diff --git a/jungle b/jungle
980 980 new file mode 100644
981 981 --- /dev/null
982 982 +++ b/jungle
983 983 @@ -0,0 +1,1 @@
984 984 +babar
985 985
986 986 Test shelve --delete
987 987
988 988 $ hg shelve --list
989 989 default (*s ago) * changes to: create conflict (glob)
990 990 $ hg shelve --delete doesnotexist
991 991 abort: shelved change 'doesnotexist' not found
992 992 [10]
993 993 $ hg shelve --delete default
994 994
995 995 $ cd ..
996 996
997 997 Test visibility of in-memory changes inside transaction to external hook
998 998 ------------------------------------------------------------------------
999 999
1000 1000 $ cd repo
1001 1001
1002 1002 $ echo xxxx >> x
1003 1003 $ hg commit -m "#5: changes to invoke rebase"
1004 1004
1005 1005 $ cat > $TESTTMP/checkvisibility.sh <<EOF
1006 1006 > echo "==== \$1:"
1007 1007 > hg parents --template "VISIBLE {rev}:{node|short}\n"
1008 1008 > # test that pending changes are hidden
1009 1009 > unset HG_PENDING
1010 1010 > hg parents --template "ACTUAL {rev}:{node|short}\n"
1011 1011 > echo "===="
1012 1012 > EOF
1013 1013
1014 1014 $ cat >> .hg/hgrc <<EOF
1015 1015 > [defaults]
1016 1016 > # to fix hash id of temporary revisions
1017 1017 > unshelve = --date '0 0'
1018 1018 > EOF
1019 1019
1020 1020 "hg unshelve" at REV5 implies steps below:
1021 1021
1022 1022 (1) commit changes in the working directory (REV6)
1023 1023 (2) unbundle shelved revision (REV7)
1024 1024 (3) rebase: merge REV7 into REV6 (REV6 => REV6, REV7)
1025 1025 (4) rebase: commit merged revision (REV8)
1026 1026 (5) rebase: update to REV6 (REV8 => REV6)
1027 1027 (6) update to REV5 (REV6 => REV5)
1028 1028 (7) abort transaction
1029 1029
1030 1030 == test visibility to external preupdate hook
1031 1031
1032 1032 $ cat >> .hg/hgrc <<EOF
1033 1033 > [hooks]
1034 1034 > preupdate.visibility = sh $TESTTMP/checkvisibility.sh preupdate
1035 1035 > EOF
1036 1036
1037 1037 $ echo nnnn >> n
1038 1038
1039 1039 $ sh $TESTTMP/checkvisibility.sh before-unshelving
1040 1040 ==== before-unshelving:
1041 1041 VISIBLE (5|19):703117a2acfb (re)
1042 1042 ACTUAL (5|19):703117a2acfb (re)
1043 1043 ====
1044 1044
1045 1045 $ hg unshelve --keep default
1046 1046 temporarily committing pending changes (restore with 'hg unshelve --abort')
1047 1047 rebasing shelved changes
1048 1048 ==== preupdate:
1049 1049 VISIBLE (6|20):54c00d20fb3f (re)
1050 1050 ACTUAL (5|19):703117a2acfb (re)
1051 1051 ====
1052 1052 ==== preupdate:
1053 1053 VISIBLE (8|21):8efe6f7537dc (re)
1054 1054 ACTUAL (5|19):703117a2acfb (re)
1055 1055 ====
1056 1056 ==== preupdate:
1057 1057 VISIBLE (6|20):54c00d20fb3f (re)
1058 1058 ACTUAL (5|19):703117a2acfb (re)
1059 1059 ====
1060 1060
1061 1061 $ cat >> .hg/hgrc <<EOF
1062 1062 > [hooks]
1063 1063 > preupdate.visibility =
1064 1064 > EOF
1065 1065
1066 1066 $ sh $TESTTMP/checkvisibility.sh after-unshelving
1067 1067 ==== after-unshelving:
1068 1068 VISIBLE (5|19):703117a2acfb (re)
1069 1069 ACTUAL (5|19):703117a2acfb (re)
1070 1070 ====
1071 1071
1072 1072 == test visibility to external update hook
1073 1073
1074 1074 $ hg update -q -C 703117a2acfb
1075 1075
1076 1076 $ cat >> .hg/hgrc <<EOF
1077 1077 > [hooks]
1078 1078 > update.visibility = sh $TESTTMP/checkvisibility.sh update
1079 1079 > EOF
1080 1080
1081 1081 $ echo nnnn >> n
1082 1082
1083 1083 $ sh $TESTTMP/checkvisibility.sh before-unshelving
1084 1084 ==== before-unshelving:
1085 1085 VISIBLE (5|19):703117a2acfb (re)
1086 1086 ACTUAL (5|19):703117a2acfb (re)
1087 1087 ====
1088 1088
1089 1089 $ hg unshelve --keep default
1090 1090 temporarily committing pending changes (restore with 'hg unshelve --abort')
1091 1091 rebasing shelved changes
1092 1092 ==== update:
1093 1093 VISIBLE (6|20):54c00d20fb3f (re)
1094 1094 VISIBLE 1?7:492ed9d705e5 (re)
1095 1095 ACTUAL (5|19):703117a2acfb (re)
1096 1096 ====
1097 1097 ==== update:
1098 1098 VISIBLE (6|20):54c00d20fb3f (re)
1099 1099 ACTUAL (5|19):703117a2acfb (re)
1100 1100 ====
1101 1101 ==== update:
1102 1102 VISIBLE (5|19):703117a2acfb (re)
1103 1103 ACTUAL (5|19):703117a2acfb (re)
1104 1104 ====
1105 1105
1106 1106 $ cat >> .hg/hgrc <<EOF
1107 1107 > [hooks]
1108 1108 > update.visibility =
1109 1109 > EOF
1110 1110
1111 1111 $ sh $TESTTMP/checkvisibility.sh after-unshelving
1112 1112 ==== after-unshelving:
1113 1113 VISIBLE (5|19):703117a2acfb (re)
1114 1114 ACTUAL (5|19):703117a2acfb (re)
1115 1115 ====
1116 1116
1117 1117 $ cd ..
1118 1118
1119 1119 Keep active bookmark while (un)shelving even on shared repo (issue4940)
1120 1120 -----------------------------------------------------------------------
1121 1121
1122 1122 $ cat <<EOF >> $HGRCPATH
1123 1123 > [extensions]
1124 1124 > share =
1125 1125 > EOF
1126 1126
1127 1127 $ hg bookmarks -R repo
1128 1128 test (4|13):33f7f61e6c5e (re)
1129 1129 $ hg share -B repo share
1130 1130 updating working directory
1131 1131 6 files updated, 0 files merged, 0 files removed, 0 files unresolved
1132 1132 $ cd share
1133 1133
1134 1134 $ hg bookmarks
1135 1135 test (4|13):33f7f61e6c5e (re)
1136 1136 $ hg bookmarks foo
1137 1137 $ hg bookmarks
1138 1138 \* foo (5|19):703117a2acfb (re)
1139 1139 test (4|13):33f7f61e6c5e (re)
1140 1140 $ echo x >> x
1141 1141 $ hg shelve
1142 1142 shelved as foo
1143 1143 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1144 1144 $ hg bookmarks
1145 1145 \* foo (5|19):703117a2acfb (re)
1146 1146 test (4|13):33f7f61e6c5e (re)
1147 1147
1148 1148 $ hg unshelve
1149 1149 unshelving change 'foo'
1150 1150 $ hg bookmarks
1151 1151 \* foo (5|19):703117a2acfb (re)
1152 1152 test (4|13):33f7f61e6c5e (re)
1153 1153
1154 1154 $ cd ..
1155 1155
1156 1156 Abort unshelve while merging (issue5123)
1157 1157 ----------------------------------------
1158 1158
1159 1159 $ hg init issue5123
1160 1160 $ cd issue5123
1161 1161 $ echo > a
1162 1162 $ hg ci -Am a
1163 1163 adding a
1164 1164 $ hg co null
1165 1165 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1166 1166 $ echo > b
1167 1167 $ hg ci -Am b
1168 1168 adding b
1169 1169 created new head
1170 1170 $ echo > c
1171 1171 $ hg add c
1172 1172 $ hg shelve
1173 1173 shelved as default
1174 1174 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1175 1175 $ hg co 1
1176 1176 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1177 1177 $ hg merge 0
1178 1178 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1179 1179 (branch merge, don't forget to commit)
1180 1180 -- successful merge with two parents
1181 1181 $ hg log -G
1182 1182 @ changeset: 1:406bf70c274f
1183 1183 tag: tip
1184 1184 parent: -1:000000000000
1185 1185 user: test
1186 1186 date: Thu Jan 01 00:00:00 1970 +0000
1187 1187 summary: b
1188 1188
1189 1189 @ changeset: 0:ada8c9eb8252
1190 1190 user: test
1191 1191 date: Thu Jan 01 00:00:00 1970 +0000
1192 1192 summary: a
1193 1193
1194 1194 -- trying to pull in the shelve bits
1195 1195 -- unshelve should abort otherwise, it'll eat my second parent.
1196 1196 $ hg unshelve
1197 1197 abort: outstanding uncommitted merge
1198 1198 (use 'hg commit' or 'hg merge --abort')
1199 1199 [20]
1200 1200
1201 1201 $ cd ..
1202 1202
1203 1203 -- test for interactive mode on unshelve
1204 1204
1205 1205 $ hg init a
1206 1206 $ cd a
1207 1207 $ echo > b
1208 1208 $ hg ci -Am b
1209 1209 adding b
1210 1210 $ echo > c
1211 1211 $ echo > d
1212 1212 $ hg add .
1213 1213 adding c
1214 1214 adding d
1215 1215 $ hg shelve
1216 1216 shelved as default
1217 1217 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1218 1218 $ echo > e
1219 1219 $ hg add e
1220 1220 $ hg ci -m e
1221 1221 $ hg shelve --patch
1222 1222 default (*s ago) * changes to: b (glob)
1223 1223
1224 1224 diff --git a/c b/c
1225 1225 new file mode 100644
1226 1226 --- /dev/null
1227 1227 +++ b/c
1228 1228 @@ -0,0 +1,1 @@
1229 1229 +
1230 1230 diff --git a/d b/d
1231 1231 new file mode 100644
1232 1232 --- /dev/null
1233 1233 +++ b/d
1234 1234 @@ -0,0 +1,1 @@
1235 1235 +
1236 1236 $ hg unshelve -i <<EOF
1237 1237 > y
1238 1238 > y
1239 1239 > y
1240 1240 > n
1241 1241 > EOF
1242 1242 unshelving change 'default'
1243 1243 rebasing shelved changes
1244 1244 diff --git a/c b/c
1245 1245 new file mode 100644
1246 1246 examine changes to 'c'?
1247 1247 (enter ? for help) [Ynesfdaq?] y
1248 1248
1249 1249 @@ -0,0 +1,1 @@
1250 1250 +
1251 1251 record change 1/2 to 'c'?
1252 1252 (enter ? for help) [Ynesfdaq?] y
1253 1253
1254 1254 diff --git a/d b/d
1255 1255 new file mode 100644
1256 1256 examine changes to 'd'?
1257 1257 (enter ? for help) [Ynesfdaq?] y
1258 1258
1259 1259 @@ -0,0 +1,1 @@
1260 1260 +
1261 1261 record change 2/2 to 'd'?
1262 1262 (enter ? for help) [Ynesfdaq?] n
1263 1263
1264 1264 $ ls -A
1265 1265 .hg
1266 1266 b
1267 1267 c
1268 1268 e
1269 1269 -- shelve should not contain `c` now
1270 1270 $ hg shelve --patch
1271 1271 default (*s ago) * changes to: b (glob)
1272 1272
1273 1273 diff --git a/d b/d
1274 1274 new file mode 100644
1275 1275 --- /dev/null
1276 1276 +++ b/d
1277 1277 @@ -0,0 +1,1 @@
1278 1278 +
1279 1279 $ hg unshelve -i <<EOF
1280 1280 > y
1281 1281 > y
1282 1282 > EOF
1283 1283 unshelving change 'default'
1284 1284 temporarily committing pending changes (restore with 'hg unshelve --abort')
1285 1285 rebasing shelved changes
1286 1286 diff --git a/d b/d
1287 1287 new file mode 100644
1288 1288 examine changes to 'd'?
1289 1289 (enter ? for help) [Ynesfdaq?] y
1290 1290
1291 1291 @@ -0,0 +1,1 @@
1292 1292 +
1293 1293 record this change to 'd'?
1294 1294 (enter ? for help) [Ynesfdaq?] y
1295 1295
1296 1296
1297 1297 $ hg status -v
1298 1298 A c
1299 1299 A d
1300 1300 $ ls -A
1301 1301 .hg
1302 1302 b
1303 1303 c
1304 1304 d
1305 1305 e
1306 1306 $ hg shelve --list
1307 1307
1308 1308 -- now, unshelve selected changes from a file
1309 1309
1310 1310 $ echo B > foo
1311 1311 $ hg add foo
1312 1312 $ hg ci -m 'add B to foo'
1313 1313 $ cat > foo <<EOF
1314 1314 > A
1315 1315 > B
1316 1316 > C
1317 1317 > EOF
1318 1318 $ echo > garbage
1319 1319 $ hg st
1320 1320 M foo
1321 1321 ? garbage
1322 1322 $ hg shelve --unknown
1323 1323 shelved as default
1324 1324 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1325 1325 $ cat foo
1326 1326 B
1327 1327 $ hg unshelve -i <<EOF
1328 1328 > y
1329 1329 > y
1330 1330 > n
1331 1331 > y
1332 1332 > y
1333 1333 > EOF
1334 1334 unshelving change 'default'
1335 1335 rebasing shelved changes
1336 1336 diff --git a/foo b/foo
1337 1337 2 hunks, 2 lines changed
1338 1338 examine changes to 'foo'?
1339 1339 (enter ? for help) [Ynesfdaq?] y
1340 1340
1341 1341 @@ -1,1 +1,2 @@
1342 1342 +A
1343 1343 B
1344 1344 record change 1/3 to 'foo'?
1345 1345 (enter ? for help) [Ynesfdaq?] y
1346 1346
1347 1347 @@ -1,1 +2,2 @@
1348 1348 B
1349 1349 +C
1350 1350 record change 2/3 to 'foo'?
1351 1351 (enter ? for help) [Ynesfdaq?] n
1352 1352
1353 1353 diff --git a/garbage b/garbage
1354 1354 new file mode 100644
1355 1355 examine changes to 'garbage'?
1356 1356 (enter ? for help) [Ynesfdaq?] y
1357 1357
1358 1358 @@ -0,0 +1,1 @@
1359 1359 +
1360 1360 record change 3/3 to 'garbage'?
1361 1361 (enter ? for help) [Ynesfdaq?] y
1362 1362
1363 1363 $ hg st
1364 1364 M foo
1365 1365 ? garbage
1366 1366 $ cat foo
1367 1367 A
1368 1368 B
1369 1369 $ hg shelve --patch
1370 1370 default (*s ago) * changes to: add B to foo (glob)
1371 1371
1372 1372 diff --git a/foo b/foo
1373 1373 --- a/foo
1374 1374 +++ b/foo
1375 1375 @@ -1,2 +1,3 @@
1376 1376 A
1377 1377 B
1378 1378 +C
1379 1379
1380 1380 -- unshelve interactive on conflicts
1381 1381
1382 1382 $ echo A >> bar1
1383 1383 $ echo A >> bar2
1384 1384 $ hg add bar1 bar2
1385 1385 $ hg ci -m 'add A to bars'
1386 1386 $ echo B >> bar1
1387 1387 $ echo B >> bar2
1388 1388 $ hg shelve
1389 1389 shelved as default-01
1390 1390 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1391 1391 $ echo C >> bar1
1392 1392 $ echo C >> bar2
1393 1393 $ hg ci -m 'add C to bars'
1394 1394 $ hg unshelve -i
1395 1395 unshelving change 'default-01'
1396 1396 rebasing shelved changes
1397 1397 merging bar1
1398 1398 warning: conflicts while merging bar1! (edit, then use 'hg resolve --mark')
1399 1399 merging bar2
1400 1400 warning: conflicts while merging bar2! (edit, then use 'hg resolve --mark')
1401 1401 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
1402 1402 [240]
1403 1403
1404 1404 $ cat > bar1 <<EOF
1405 1405 > A
1406 1406 > B
1407 1407 > C
1408 1408 > EOF
1409 1409 $ cat > bar2 <<EOF
1410 1410 > A
1411 1411 > B
1412 1412 > C
1413 1413 > EOF
1414 1414 $ hg resolve -m bar1 bar2
1415 1415 (no more unresolved files)
1416 1416 continue: hg unshelve --continue
1417 1417
1418 1418 -- using --continue with --interactive should throw an error
1419 1419 $ hg unshelve --continue -i
1420 1420 abort: cannot use both continue and interactive
1421 1421 [10]
1422 1422
1423 1423 $ cat bar1
1424 1424 A
1425 1425 B
1426 1426 C
1427 1427
1428 1428 #if stripbased
1429 1429 $ hg log -r 3:: -G
1430 1430 @ changeset: 5:f1d5f53e397b
1431 1431 | tag: tip
1432 1432 | parent: 3:e28fd7fa7938
1433 1433 | user: shelve@localhost
1434 1434 | date: Thu Jan 01 00:00:00 1970 +0000
1435 1435 | summary: changes to: add A to bars
1436 1436 |
1437 1437 | @ changeset: 4:fe451a778c81
1438 1438 |/ user: test
1439 1439 | date: Thu Jan 01 00:00:00 1970 +0000
1440 1440 | summary: add C to bars
1441 1441 |
1442 1442 o changeset: 3:e28fd7fa7938
1443 1443 | user: test
1444 1444 ~ date: Thu Jan 01 00:00:00 1970 +0000
1445 1445 summary: add A to bars
1446 1446
1447 1447 #endif
1448 1448
1449 1449 $ hg unshelve --continue <<EOF
1450 1450 > y
1451 1451 > y
1452 1452 > y
1453 1453 > n
1454 1454 > EOF
1455 1455 diff --git a/bar1 b/bar1
1456 1456 1 hunks, 1 lines changed
1457 1457 examine changes to 'bar1'?
1458 1458 (enter ? for help) [Ynesfdaq?] y
1459 1459
1460 1460 @@ -1,2 +1,3 @@
1461 1461 A
1462 1462 +B
1463 1463 C
1464 1464 record change 1/2 to 'bar1'?
1465 1465 (enter ? for help) [Ynesfdaq?] y
1466 1466
1467 1467 diff --git a/bar2 b/bar2
1468 1468 1 hunks, 1 lines changed
1469 1469 examine changes to 'bar2'?
1470 1470 (enter ? for help) [Ynesfdaq?] y
1471 1471
1472 1472 @@ -1,2 +1,3 @@
1473 1473 A
1474 1474 +B
1475 1475 C
1476 1476 record change 2/2 to 'bar2'?
1477 1477 (enter ? for help) [Ynesfdaq?] n
1478 1478
1479 1479 unshelve of 'default-01' complete
1480 1480
1481 1481 #if stripbased
1482 1482 $ hg log -r 3:: -G
1483 1483 @ changeset: 4:fe451a778c81
1484 1484 | tag: tip
1485 1485 | user: test
1486 1486 | date: Thu Jan 01 00:00:00 1970 +0000
1487 1487 | summary: add C to bars
1488 1488 |
1489 1489 o changeset: 3:e28fd7fa7938
1490 1490 | user: test
1491 1491 ~ date: Thu Jan 01 00:00:00 1970 +0000
1492 1492 summary: add A to bars
1493 1493
1494 1494 #endif
1495 1495
1496 1496 $ hg unshelve --continue
1497 1497 abort: no unshelve in progress
1498 1498 [20]
1499 1499
1500 1500 $ hg shelve --list
1501 1501 default-01 (*)* changes to: add A to bars (glob)
1502 1502 default (*)* changes to: add B to foo (glob)
1503 1503 $ hg unshelve -n default-01 -i <<EOF
1504 1504 > y
1505 1505 > y
1506 1506 > EOF
1507 1507 temporarily committing pending changes (restore with 'hg unshelve --abort')
1508 1508 rebasing shelved changes
1509 1509 diff --git a/bar2 b/bar2
1510 1510 1 hunks, 1 lines changed
1511 1511 examine changes to 'bar2'?
1512 1512 (enter ? for help) [Ynesfdaq?] y
1513 1513
1514 1514 @@ -1,2 +1,3 @@
1515 1515 A
1516 1516 +B
1517 1517 C
1518 1518 record this change to 'bar2'?
1519 1519 (enter ? for help) [Ynesfdaq?] y
1520 1520
1521 1521 -- test for --interactive --keep
1522 1522 $ hg unshelve -i --keep
1523 1523 abort: --keep on --interactive is not yet supported
1524 1524 [10]
1525 1525
1526 1526 $ hg update -q --clean .
1527 1527
1528 1528 Test that we can successfully shelve and unshelve a file with a trailing space
1529 1529 in the filename. Such filenames are supposedly unsupported on Windows, so we
1530 1530 wrap it in the no-windows check. Also test `hg patch` of the .patch file
1531 1531 produced by `hg shelve`.
1532 1532 #if no-windows
1533 1533 $ echo hi > 'my filename '
1534 1534 $ hg add 'my filename '
1535 1535 warning: filename ends with ' ', which is not allowed on Windows: 'my filename '
1536 1536 $ hg shelve
1537 1537 shelved as default-01
1538 1538 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1539 1539 $ cp .hg/shelved/default-01.patch test_patch.patch
1540 1540 $ hg unshelve
1541 1541 unshelving change 'default-01'
1542 1542 $ cat 'my filename '
1543 1543 hi
1544 1544 $ hg update -q --clean .
1545 1545 $ hg patch -p1 test_patch.patch
1546 1546 applying test_patch.patch
1547 1547
1548 1548 $ hg strip -q -r .
1549 1549 #endif
1550 1550
1551 1551 Check the comment of the last commit for consistency
1552 1552
1553 1553 $ hg log -r . --template '{desc}\n'
1554 1554 add C to bars
1555 1555
1556 1556 -- if phasebased, shelve works without patch and bundle
1557 1557
1558 1558 $ hg update -q --clean .
1559 1559 $ rm -r .hg/shelve*
1560 1560 $ echo import antigravity >> somefile.py
1561 1561 $ hg add somefile.py
1562 1562 $ hg shelve -q
1563 1563 #if phasebased
1564 1564 $ rm .hg/shelved/default.hg
1565 1565 $ rm .hg/shelved/default.patch
1566 1566 #endif
1567 1567
1568 1568 shelve --list --patch should work even with no patch file.
1569 1569
1570 1570 $ hg shelve --list --patch
1571 1571 default (*s ago) * changes to: add C to bars (glob)
1572 1572
1573 1573 diff --git a/somefile.py b/somefile.py
1574 1574 new file mode 100644
1575 1575 --- /dev/null
1576 1576 +++ b/somefile.py
1577 1577 @@ -0,0 +1,1 @@
1578 1578 +import antigravity
1579 1579
1580 1580 $ hg unshelve
1581 1581 unshelving change 'default'
1582 1582
1583 1583 #if phasebased
1584 1584 $ ls .hg/shelve-backup
1585 1585 default.shelve
1586 1586 #endif
1587 1587
1588 1588 #if stripbased
1589 1589 $ ls .hg/shelve-backup
1590 1590 default.hg
1591 1591 default.patch
1592 1592 default.shelve
1593 1593 #endif
1594 1594
1595 1595
1596 1596 -- allow for phase-based shelves to be disabled
1597 1597
1598 1598 $ hg update -q --clean .
1599 1599 $ hg strip -q --hidden -r 0
1600 1600 $ rm -r .hg/shelve*
1601 1601
1602 1602 #if phasebased
1603 $ cp $HGRCPATH $TESTTMP/hgrc-saved
1603 1604 $ cat <<EOF >> $HGRCPATH
1604 1605 > [shelve]
1605 1606 > store = strip
1606 1607 > EOF
1607 1608 #endif
1608 1609
1609 1610 $ echo import this >> somefile.py
1610 1611 $ hg add somefile.py
1611 1612 $ hg shelve -q
1612 1613 $ hg log --hidden
1613 1614 $ ls .hg/shelved
1614 1615 default.hg
1615 1616 default.patch
1616 1617 default.shelve
1617 1618 $ hg unshelve -q
1618 1619
1619 1620 Override the disabling, re-enabling phase-based shelves
1620 1621
1621 1622 $ hg shelve --config shelve.store=internal -q
1622 1623
1623 1624 #if phasebased
1624 1625 $ hg log --hidden --template '{user}\n'
1625 1626 shelve@localhost
1626 1627 #endif
1627 1628
1628 1629 #if stripbased
1629 1630 $ hg log --hidden --template '{user}\n'
1630 1631 #endif
1632
1633 clean up
1634
1635 #if phasebased
1636 $ mv $TESTTMP/hgrc-saved $HGRCPATH
1637 #endif
1638
1639 changed files should be reachable in all shelves
1640
1641 create an extension that emits changed files
1642
1643 $ cat > shelve-changed-files.py << EOF
1644 > """Command to emit changed files for a shelf"""
1645 >
1646 > from mercurial import registrar, shelve
1647 >
1648 > cmdtable = {}
1649 > command = registrar.command(cmdtable)
1650 >
1651 >
1652 > @command(b'shelve-changed-files')
1653 > def shelve_changed_files(ui, repo, name):
1654 > shelf = shelve.ShelfDir(repo).get(name)
1655 > for file in shelf.changed_files(ui, repo):
1656 > ui.write(file + b'\n')
1657 > EOF
1658
1659 $ hg --config extensions.shelve-changed-files=shelve-changed-files.py shelve-changed-files default
1660 somefile.py
General Comments 0
You need to be logged in to leave comments. Login now