Debian Codegraph @

tests/test-mq.t

raw
1 $ checkundo()
2 > {
3 > if [ -f .hg/store/undo ]; then
4 > echo ".hg/store/undo still exists after $1"
5 > fi
6 > }
7
8 $ cat <<EOF >> $HGRCPATH
9 > [extensions]
10 > mq =
11 > [mq]
12 > plain = true
13 > EOF
14
15
16 help
17
18 $ hg help mq
19 mq extension - manage a stack of patches
20
21 This extension lets you work with a stack of patches in a Mercurial
22 repository. It manages two stacks of patches - all known patches, and applied
23 patches (subset of known patches).
24
25 Known patches are represented as patch files in the .hg/patches directory.
26 Applied patches are both patch files and changesets.
27
28 Common tasks (use 'hg help COMMAND' for more details):
29
30 create new patch qnew
31 import existing patch qimport
32
33 print patch series qseries
34 print applied patches qapplied
35
36 add known patch to applied stack qpush
37 remove patch from applied stack qpop
38 refresh contents of top applied patch qrefresh
39
40 By default, mq will automatically use git patches when required to avoid
41 losing file mode changes, copy records, binary files or empty files creations
42 or deletions. This behavior can be configured with:
43
44 [mq]
45 git = auto/keep/yes/no
46
47 If set to 'keep', mq will obey the [diff] section configuration while
48 preserving existing git patches upon qrefresh. If set to 'yes' or 'no', mq
49 will override the [diff] section and always generate git or regular patches,
50 possibly losing data in the second case.
51
52 It may be desirable for mq changesets to be kept in the secret phase (see 'hg
53 help phases'), which can be enabled with the following setting:
54
55 [mq]
56 secret = True
57
58 You will by default be managing a patch queue named "patches". You can create
59 other, independent patch queues with the 'hg qqueue' command.
60
61 If the working directory contains uncommitted files, qpush, qpop and qgoto
62 abort immediately. If -f/--force is used, the changes are discarded. Setting:
63
64 [mq]
65 keepchanges = True
66
67 make them behave as if --keep-changes were passed, and non-conflicting local
68 changes will be tolerated and preserved. If incompatible options such as
69 -f/--force or --exact are passed, this setting is ignored.
70
71 This extension used to provide a strip command. This command now lives in the
72 strip extension.
73
74 list of commands:
75
76 Repository creation:
77
78 qclone clone main and patch repository at same time
79
80 Change creation:
81
82 qnew create a new patch
83 qrefresh update the current patch
84
85 Change manipulation:
86
87 qfold fold the named patches into the current patch
88
89 Change organization:
90
91 qapplied print the patches already applied
92 qdelete remove patches from queue
93 qfinish move applied patches into repository history
94 qgoto push or pop patches until named patch is at top of stack
95 qguard set or print guards for a patch
96 qheader print the header of the topmost or specified patch
97 qnext print the name of the next pushable patch
98 qpop pop the current patch off the stack
99 qprev print the name of the preceding applied patch
100 qpush push the next patch onto the stack
101 qqueue manage multiple patch queues
102 qrename rename a patch
103 qselect set or print guarded patches to push
104 qseries print the entire series file
105 qtop print the name of the current patch
106 qunapplied print the patches not yet applied
107
108 File content management:
109
110 qdiff diff of the current patch and subsequent modifications
111
112 Change import/export:
113
114 qimport import a patch or existing changeset
115
116 (use 'hg help -v mq' to show built-in aliases and global options)
117
118 $ hg init a
119 $ cd a
120 $ echo a > a
121 $ hg ci -Ama
122 adding a
123
124 $ hg clone . ../k
125 updating to branch default
126 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
127
128 $ mkdir b
129 $ echo z > b/z
130 $ hg ci -Ama
131 adding b/z
132
133
134 qinit
135
136 $ hg qinit
137
138 $ cd ..
139 $ hg init b
140
141
142 -R qinit
143
144 $ hg -R b qinit
145
146 $ hg init c
147
148
149 qinit -c
150
151 $ hg --cwd c qinit -c
152 $ hg -R c/.hg/patches st
153 A .hgignore
154 A series
155
156
157 qinit; qinit -c
158
159 $ hg init d
160 $ cd d
161 $ hg qinit
162 $ hg qinit -c
163
164 qinit -c should create both files if they don't exist
165
166 $ cat .hg/patches/.hgignore
167 ^\.hg
168 ^\.mq
169 syntax: glob
170 status
171 guards
172 $ cat .hg/patches/series
173 $ hg qinit -c
174 abort: repository $TESTTMP/d/.hg/patches already exists
175 [255]
176 $ cd ..
177
178 $ echo '% qinit; <stuff>; qinit -c'
179 % qinit; <stuff>; qinit -c
180 $ hg init e
181 $ cd e
182 $ hg qnew A
183 $ checkundo qnew
184 $ echo foo > foo
185 $ hg phase -r qbase
186 0: draft
187 $ hg add foo
188 $ hg qrefresh
189 $ hg phase -r qbase
190 0: draft
191 $ hg qnew B
192 $ echo >> foo
193 $ hg qrefresh
194 $ echo status >> .hg/patches/.hgignore
195 $ echo bleh >> .hg/patches/.hgignore
196 $ hg qinit -c
197 adding .hg/patches/A
198 adding .hg/patches/B
199 $ hg -R .hg/patches status
200 A .hgignore
201 A A
202 A B
203 A series
204
205 qinit -c shouldn't touch these files if they already exist
206
207 $ cat .hg/patches/.hgignore
208 status
209 bleh
210 $ cat .hg/patches/series
211 A
212 B
213
214 add an untracked file
215
216 $ echo >> .hg/patches/flaf
217
218 status --mq with color (issue2096)
219
220 $ hg status --mq --config extensions.color= --config color.mode=ansi --color=always
221 \x1b[0;32;1mA \x1b[0m\x1b[0;32;1m.hgignore\x1b[0m (esc)
222 \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mA\x1b[0m (esc)
223 \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mB\x1b[0m (esc)
224 \x1b[0;32;1mA \x1b[0m\x1b[0;32;1mseries\x1b[0m (esc)
225 \x1b[0;35;1;4m? \x1b[0m\x1b[0;35;1;4mflaf\x1b[0m (esc)
226
227 try the --mq option on a command provided by an extension
228
229 $ hg purge --mq --verbose --config extensions.purge=
230 removing file flaf
231
232 $ cd ..
233
234 #if no-outer-repo
235
236 init --mq without repo
237
238 $ mkdir f
239 $ cd f
240 $ hg init --mq
241 abort: there is no Mercurial repository here (.hg not found)
242 [255]
243 $ cd ..
244
245 #endif
246
247 init --mq with repo path
248
249 $ hg init g
250 $ hg init --mq g
251 $ test -d g/.hg/patches/.hg
252
253 init --mq with nonexistent directory
254
255 $ hg init --mq nonexistentdir
256 abort: repository nonexistentdir not found
257 [255]
258
259
260 init --mq with bundle (non "local")
261
262 $ hg -R a bundle --all a.bundle >/dev/null
263 $ hg init --mq a.bundle
264 abort: only a local queue repository may be initialized
265 [255]
266
267 $ cd a
268
269 $ hg qnew -m 'foo bar' test.patch
270
271 $ echo '# comment' > .hg/patches/series.tmp
272 $ echo >> .hg/patches/series.tmp # empty line
273 $ cat .hg/patches/series >> .hg/patches/series.tmp
274 $ mv .hg/patches/series.tmp .hg/patches/series
275
276
277 qrefresh
278
279 $ echo a >> a
280 $ hg qrefresh
281 $ cat .hg/patches/test.patch
282 foo bar
283
284 diff -r [a-f0-9]* a (re)
285 --- a/a\t(?P<date>.*) (re)
286 \+\+\+ b/a\t(?P<date2>.*) (re)
287 @@ -1,1 +1,2 @@
288 a
289 +a
290
291 empty qrefresh
292
293 $ hg qrefresh -X a
294
295 revision:
296
297 $ hg diff -r -2 -r -1
298
299 patch:
300
301 $ cat .hg/patches/test.patch
302 foo bar
303
304
305 working dir diff:
306
307 $ hg diff --nodates -q
308 diff -r dde259bd5934 a
309 --- a/a
310 +++ b/a
311 @@ -1,1 +1,2 @@
312 a
313 +a
314
315 restore things
316
317 $ hg qrefresh
318 $ checkundo qrefresh
319
320
321 qpop
322
323 $ hg qpop
324 popping test.patch
325 patch queue now empty
326 $ checkundo qpop
327
328
329 qpush with dump of tag cache
330 Dump the tag cache to ensure that it has exactly one head after qpush.
331
332 $ rm -f .hg/cache/tags2-visible
333 $ hg tags > /dev/null
334
335 .hg/cache/tags2-visible (pre qpush):
336
337 $ cat .hg/cache/tags2-visible
338 1 [\da-f]{40} (re)
339 $ hg qpush
340 applying test.patch
341 now at: test.patch
342 $ hg phase -r qbase
343 2: draft
344 $ hg tags > /dev/null
345
346 .hg/cache/tags2-visible (post qpush):
347
348 $ cat .hg/cache/tags2-visible
349 2 [\da-f]{40} (re)
350 $ checkundo qpush
351 $ cd ..
352
353
354 pop/push outside repo
355 $ hg -R a qpop
356 popping test.patch
357 patch queue now empty
358 $ hg -R a qpush
359 applying test.patch
360 now at: test.patch
361
362 $ cd a
363 $ hg qnew test2.patch
364
365 qrefresh in subdir
366
367 $ cd b
368 $ echo a > a
369 $ hg add a
370 $ hg qrefresh
371
372 pop/push -a in subdir
373
374 $ hg qpop -a
375 popping test2.patch
376 popping test.patch
377 patch queue now empty
378 $ hg --traceback qpush -a
379 applying test.patch
380 applying test2.patch
381 now at: test2.patch
382
383
384 setting columns & formatted tests truncating (issue1912)
385
386 $ COLUMNS=4 hg qseries --config ui.formatted=true --color=no
387 test.patch
388 test2.patch
389 $ COLUMNS=20 hg qseries --config ui.formatted=true -vs --color=no
390 0 A test.patch: f...
391 1 A test2.patch:
392 $ hg qpop
393 popping test2.patch
394 now at: test.patch
395 $ hg qseries -vs
396 0 A test.patch: foo bar
397 1 U test2.patch:
398 $ hg sum | grep mq
399 mq: 1 applied, 1 unapplied
400 $ hg qpush
401 applying test2.patch
402 now at: test2.patch
403 $ hg sum | grep mq
404 mq: 2 applied
405 $ hg qapplied
406 test.patch
407 test2.patch
408 $ hg qtop
409 test2.patch
410
411
412 prev
413
414 $ hg qapp -1
415 test.patch
416
417 next
418
419 $ hg qunapp -1
420 all patches applied
421 [1]
422
423 $ hg qpop
424 popping test2.patch
425 now at: test.patch
426
427 commit should fail
428
429 $ hg commit
430 abort: cannot commit over an applied mq patch
431 [255]
432
433 push should fail if draft
434
435 $ hg push ../../k
436 pushing to ../../k
437 abort: source has mq patches applied
438 [255]
439
440
441 import should fail
442
443 $ hg st .
444 $ echo foo >> ../a
445 $ hg diff > ../../import.diff
446 $ hg revert --no-backup ../a
447 $ hg import ../../import.diff
448 abort: cannot import over an applied patch
449 [255]
450 $ hg st
451
452 import --no-commit should succeed
453
454 $ hg import --no-commit ../../import.diff
455 applying ../../import.diff
456 $ hg st
457 M a
458 $ hg revert --no-backup ../a
459
460
461 qunapplied
462
463 $ hg qunapplied
464 test2.patch
465
466
467 qpush/qpop with index
468
469 $ hg qnew test1b.patch
470 $ echo 1b > 1b
471 $ hg add 1b
472 $ hg qrefresh
473 $ hg qpush 2
474 applying test2.patch
475 now at: test2.patch
476 $ hg qpop 0
477 popping test2.patch
478 popping test1b.patch
479 now at: test.patch
480 $ hg qpush test.patch+1
481 applying test1b.patch
482 now at: test1b.patch
483 $ hg qpush test.patch+2
484 applying test2.patch
485 now at: test2.patch
486 $ hg qpop test2.patch-1
487 popping test2.patch
488 now at: test1b.patch
489 $ hg qpop test2.patch-2
490 popping test1b.patch
491 now at: test.patch
492 $ hg qpush test1b.patch+1
493 applying test1b.patch
494 applying test2.patch
495 now at: test2.patch
496
497
498 qpush --move
499
500 $ hg qpop -a
501 popping test2.patch
502 popping test1b.patch
503 popping test.patch
504 patch queue now empty
505 $ hg qguard test1b.patch -- -negguard
506 $ hg qguard test2.patch -- +posguard
507 $ hg qpush --move test2.patch # can't move guarded patch
508 cannot push 'test2.patch' - guarded by '+posguard'
509 [1]
510 $ hg qselect posguard
511 number of unguarded, unapplied patches has changed from 2 to 3
512 $ hg qpush --move test2.patch # move to front
513 applying test2.patch
514 now at: test2.patch
515 $ hg qpush --move test1b.patch # negative guard unselected
516 applying test1b.patch
517 now at: test1b.patch
518 $ hg qpush --move test.patch # noop move
519 applying test.patch
520 now at: test.patch
521 $ hg qseries -v
522 0 A test2.patch
523 1 A test1b.patch
524 2 A test.patch
525 $ hg qpop -a
526 popping test.patch
527 popping test1b.patch
528 popping test2.patch
529 patch queue now empty
530
531 cleaning up
532
533 $ hg qselect --none
534 guards deactivated
535 number of unguarded, unapplied patches has changed from 3 to 2
536 $ hg qguard --none test1b.patch
537 $ hg qguard --none test2.patch
538 $ hg qpush --move test.patch
539 applying test.patch
540 now at: test.patch
541 $ hg qpush --move test1b.patch
542 applying test1b.patch
543 now at: test1b.patch
544 $ hg qpush --move bogus # nonexistent patch
545 abort: patch bogus not in series
546 [255]
547 $ hg qpush --move # no patch
548 abort: please specify the patch to move
549 [255]
550 $ hg qpush --move test.patch # already applied
551 abort: cannot push to a previous patch: test.patch
552 [255]
553 $ sed '2i\
554 > # make qtip index different in series and fullseries
555 > ' `hg root`/.hg/patches/series > $TESTTMP/sedtmp
556 $ cp $TESTTMP/sedtmp `hg root`/.hg/patches/series
557 $ cat `hg root`/.hg/patches/series
558 # comment
559 # make qtip index different in series and fullseries
560
561 test.patch
562 test1b.patch
563 test2.patch
564 $ hg qpush --move test2.patch
565 applying test2.patch
566 now at: test2.patch
567
568
569 series after move
570
571 $ cat `hg root`/.hg/patches/series
572 # comment
573 # make qtip index different in series and fullseries
574
575 test.patch
576 test1b.patch
577 test2.patch
578
579
580 pop, qapplied, qunapplied
581
582 $ hg qseries -v
583 0 A test.patch
584 1 A test1b.patch
585 2 A test2.patch
586
587 qapplied -1 test.patch
588
589 $ hg qapplied -1 test.patch
590 only one patch applied
591 [1]
592
593 qapplied -1 test1b.patch
594
595 $ hg qapplied -1 test1b.patch
596 test.patch
597
598 qapplied -1 test2.patch
599
600 $ hg qapplied -1 test2.patch
601 test1b.patch
602
603 qapplied -1
604
605 $ hg qapplied -1
606 test1b.patch
607
608 qapplied
609
610 $ hg qapplied
611 test.patch
612 test1b.patch
613 test2.patch
614
615 qapplied test1b.patch
616
617 $ hg qapplied test1b.patch
618 test.patch
619 test1b.patch
620
621 qunapplied -1
622
623 $ hg qunapplied -1
624 all patches applied
625 [1]
626
627 qunapplied
628
629 $ hg qunapplied
630
631 popping
632
633 $ hg qpop
634 popping test2.patch
635 now at: test1b.patch
636
637 qunapplied -1
638
639 $ hg qunapplied -1
640 test2.patch
641
642 qunapplied
643
644 $ hg qunapplied
645 test2.patch
646
647 qunapplied test2.patch
648
649 $ hg qunapplied test2.patch
650
651 qunapplied -1 test2.patch
652
653 $ hg qunapplied -1 test2.patch
654 all patches applied
655 [1]
656
657 popping -a
658
659 $ hg qpop -a
660 popping test1b.patch
661 popping test.patch
662 patch queue now empty
663
664 qapplied
665
666 $ hg qapplied
667
668 qapplied -1
669
670 $ hg qapplied -1
671 no patches applied
672 [1]
673 $ hg qpush
674 applying test.patch
675 now at: test.patch
676
677
678 push should succeed
679
680 $ hg qpop -a
681 popping test.patch
682 patch queue now empty
683 $ hg push ../../k
684 pushing to ../../k
685 searching for changes
686 adding changesets
687 adding manifests
688 adding file changes
689 added 1 changesets with 1 changes to 1 files
690
691
692 we want to start with some patches applied
693
694 $ hg qpush -a
695 applying test.patch
696 applying test1b.patch
697 applying test2.patch
698 now at: test2.patch
699
700 % pops all patches and succeeds
701
702 $ hg qpop -a
703 popping test2.patch
704 popping test1b.patch
705 popping test.patch
706 patch queue now empty
707
708 % does nothing and succeeds
709
710 $ hg qpop -a
711 no patches applied
712
713 % fails - nothing else to pop
714
715 $ hg qpop
716 no patches applied
717 [1]
718
719 % pushes a patch and succeeds
720
721 $ hg qpush
722 applying test.patch
723 now at: test.patch
724
725 % pops a patch and succeeds
726
727 $ hg qpop
728 popping test.patch
729 patch queue now empty
730
731 % pushes up to test1b.patch and succeeds
732
733 $ hg qpush test1b.patch
734 applying test.patch
735 applying test1b.patch
736 now at: test1b.patch
737
738 % does nothing and succeeds
739
740 $ hg qpush test1b.patch
741 qpush: test1b.patch is already at the top
742
743 % does nothing and succeeds
744
745 $ hg qpop test1b.patch
746 qpop: test1b.patch is already at the top
747
748 % fails - can't push to this patch
749
750 $ hg qpush test.patch
751 abort: cannot push to a previous patch: test.patch
752 [255]
753
754 % fails - can't pop to this patch
755
756 $ hg qpop test2.patch
757 abort: patch test2.patch is not applied
758 [255]
759
760 % pops up to test.patch and succeeds
761
762 $ hg qpop test.patch
763 popping test1b.patch
764 now at: test.patch
765
766 % pushes all patches and succeeds
767
768 $ hg qpush -a
769 applying test1b.patch
770 applying test2.patch
771 now at: test2.patch
772
773 % does nothing and succeeds
774
775 $ hg qpush -a
776 all patches are currently applied
777
778 % fails - nothing else to push
779
780 $ hg qpush
781 patch series already fully applied
782 [1]
783
784 % does nothing and succeeds
785
786 $ hg qpush test2.patch
787 qpush: test2.patch is already at the top
788
789 strip
790
791 $ cd ../../b
792 $ echo x>x
793 $ hg ci -Ama
794 adding x
795 $ hg strip tip
796 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
797 saved backup bundle to $TESTTMP/b/.hg/strip-backup/*-backup.hg (glob)
798 $ hg unbundle .hg/strip-backup/*
799 adding changesets
800 adding manifests
801 adding file changes
802 added 1 changesets with 1 changes to 1 files
803 new changesets 770eb8fce608 (1 drafts)
804 (run 'hg update' to get a working copy)
805
806
807 strip with local changes, should complain
808
809 $ hg up
810 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
811 $ echo y>y
812 $ hg add y
813 $ hg strip tip
814 abort: uncommitted changes
815 [20]
816
817 --force strip with local changes
818
819 $ hg strip -f tip
820 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
821 saved backup bundle to $TESTTMP/b/.hg/strip-backup/770eb8fce608-0ddcae0f-backup.hg
822 $ cd ..
823
824
825 cd b; hg qrefresh
826
827 $ hg init refresh
828 $ cd refresh
829 $ echo a > a
830 $ hg ci -Ama
831 adding a
832 $ hg qnew -mfoo foo
833 $ echo a >> a
834 $ hg qrefresh
835 $ mkdir b
836 $ cd b
837 $ echo f > f
838 $ hg add f
839 $ hg qrefresh
840 $ cat ../.hg/patches/foo
841 foo
842
843 diff -r cb9a9f314b8b a
844 --- a/a\t(?P<date>.*) (re)
845 \+\+\+ b/a\t(?P<date>.*) (re)
846 @@ -1,1 +1,2 @@
847 a
848 +a
849 diff -r cb9a9f314b8b b/f
850 --- /dev/null\t(?P<date>.*) (re)
851 \+\+\+ b/b/f\t(?P<date>.*) (re)
852 @@ -0,0 +1,1 @@
853 +f
854
855 hg qrefresh .
856
857 $ hg qrefresh .
858 $ cat ../.hg/patches/foo
859 foo
860
861 diff -r cb9a9f314b8b b/f
862 --- /dev/null\t(?P<date>.*) (re)
863 \+\+\+ b/b/f\t(?P<date>.*) (re)
864 @@ -0,0 +1,1 @@
865 +f
866 $ hg status
867 M a
868
869
870 qpush failure
871
872 $ cd ..
873 $ hg qrefresh
874 $ hg qnew -mbar bar
875 $ echo foo > foo
876 $ echo bar > bar
877 $ hg add foo bar
878 $ hg qrefresh
879 $ hg qpop -a
880 popping bar
881 popping foo
882 patch queue now empty
883 $ echo bar > foo
884 $ hg qpush -a
885 applying foo
886 applying bar
887 file foo already exists
888 1 out of 1 hunks FAILED -- saving rejects to file foo.rej
889 patch failed, unable to continue (try -v)
890 patch failed, rejects left in working directory
891 errors during apply, please fix and qrefresh bar
892 [2]
893 $ hg st
894 ? foo
895 ? foo.rej
896
897
898 mq tags
899
900 $ hg log --template '{rev} {tags}\n' -r qparent:qtip
901 0 qparent
902 1 foo qbase
903 2 bar qtip tip
904
905 mq revset
906
907 $ hg log -r 'mq()' --template '{rev}\n'
908 1
909 2
910 $ hg help revisions.mq
911 "mq()"
912 Changesets managed by MQ.
913
914
915 bad node in status
916
917 $ hg qpop
918 popping bar
919 now at: foo
920 $ hg strip -qn tip
921 $ hg tip
922 changeset: 0:cb9a9f314b8b
923 tag: tip
924 user: test
925 date: Thu Jan 01 00:00:00 1970 +0000
926 summary: a
927
928 $ hg branches
929 default 0:cb9a9f314b8b
930 $ hg qpop
931 no patches applied
932 [1]
933
934 $ cd ..
935
936
937 git patches
938
939 $ cat >>$HGRCPATH <<EOF
940 > [diff]
941 > git = True
942 > EOF
943 $ hg init git
944 $ cd git
945 $ hg qinit
946
947 $ hg qnew -m'new file' new
948 $ echo foo > new
949 #if execbit
950 $ chmod +x new
951 #endif
952 $ hg add new
953 $ hg qrefresh
954
955 $ cat .hg/patches/new
956 new file
957
958 diff --git a/new b/new
959 new file mode 100755 (execbit !)
960 new file mode 100644 (no-execbit !)
961 --- /dev/null
962 +++ b/new
963 @@ -0,0 +1,1 @@
964 +foo
965
966 $ hg qnew -m'copy file' copy
967 $ hg cp new copy
968 $ hg qrefresh
969 $ cat .hg/patches/copy
970 copy file
971
972 diff --git a/new b/copy
973 copy from new
974 copy to copy
975
976 $ hg qpop
977 popping copy
978 now at: new
979 $ hg qpush
980 applying copy
981 now at: copy
982 $ hg qdiff
983 diff --git a/new b/copy
984 copy from new
985 copy to copy
986 $ cat >>$HGRCPATH <<EOF
987 > [diff]
988 > git = False
989 > EOF
990 $ hg qdiff --git
991 diff --git a/new b/copy
992 copy from new
993 copy to copy
994 $ cd ..
995
996 empty lines in status
997
998 $ hg init emptystatus
999 $ cd emptystatus
1000 $ hg qinit
1001 $ printf '\n\n' > .hg/patches/status
1002 $ hg qser
1003 $ cd ..
1004
1005 bad line in status (without ":")
1006
1007 $ hg init badstatus
1008 $ cd badstatus
1009 $ hg qinit
1010 $ printf 'babar has no colon in this line\n' > .hg/patches/status
1011 $ hg qser
1012 malformated mq status line: ['babar has no colon in this line']
1013 $ cd ..
1014
1015
1016 test file addition in slow path
1017
1018 $ hg init slow
1019 $ cd slow
1020 $ hg qinit
1021 $ echo foo > foo
1022 $ hg add foo
1023 $ hg ci -m 'add foo'
1024 $ hg qnew bar
1025 $ echo bar > bar
1026 $ hg add bar
1027 $ hg mv foo baz
1028 $ hg qrefresh --git
1029 $ hg up -C 0
1030 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
1031 $ echo >> foo
1032 $ hg ci -m 'change foo'
1033 created new head
1034 $ hg up -C 1
1035 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1036 $ hg qrefresh --git
1037 $ cat .hg/patches/bar
1038 diff --git a/bar b/bar
1039 new file mode 100644
1040 --- /dev/null
1041 +++ b/bar
1042 @@ -0,0 +1,1 @@
1043 +bar
1044 diff --git a/foo b/baz
1045 rename from foo
1046 rename to baz
1047 $ hg log -v --template '{rev} {file_copies}\n' -r .
1048 2 baz (foo)
1049 $ hg qrefresh --git
1050 $ cat .hg/patches/bar
1051 diff --git a/bar b/bar
1052 new file mode 100644
1053 --- /dev/null
1054 +++ b/bar
1055 @@ -0,0 +1,1 @@
1056 +bar
1057 diff --git a/foo b/baz
1058 rename from foo
1059 rename to baz
1060 $ hg log -v --template '{rev} {file_copies}\n' -r .
1061 2 baz (foo)
1062 $ hg qrefresh
1063 $ grep 'diff --git' .hg/patches/bar
1064 diff --git a/bar b/bar
1065 diff --git a/foo b/baz
1066
1067
1068 test file move chains in the slow path
1069
1070 $ hg up -C 1
1071 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
1072 $ echo >> foo
1073 $ hg ci -m 'change foo again'
1074 $ hg up -C 2
1075 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
1076 $ hg mv bar quux
1077 $ hg mv baz bleh
1078 $ hg qrefresh --git
1079 $ cat .hg/patches/bar
1080 diff --git a/foo b/bleh
1081 rename from foo
1082 rename to bleh
1083 diff --git a/quux b/quux
1084 new file mode 100644
1085 --- /dev/null
1086 +++ b/quux
1087 @@ -0,0 +1,1 @@
1088 +bar
1089 $ hg log -v --template '{rev} {file_copies}\n' -r .
1090 3 bleh (foo)
1091 $ hg mv quux fred
1092 $ hg mv bleh barney
1093 $ hg qrefresh --git
1094 $ cat .hg/patches/bar
1095 diff --git a/foo b/barney
1096 rename from foo
1097 rename to barney
1098 diff --git a/fred b/fred
1099 new file mode 100644
1100 --- /dev/null
1101 +++ b/fred
1102 @@ -0,0 +1,1 @@
1103 +bar
1104 $ hg log -v --template '{rev} {file_copies}\n' -r .
1105 3 barney (foo)
1106
1107
1108 refresh omitting an added file
1109
1110 $ hg qnew baz
1111 $ echo newfile > newfile
1112 $ hg add newfile
1113 $ hg qrefresh
1114 $ hg st -A newfile
1115 C newfile
1116 $ hg qrefresh -X newfile
1117 $ hg st -A newfile
1118 A newfile
1119 $ hg revert newfile
1120 $ rm newfile
1121 $ hg qpop
1122 popping baz
1123 now at: bar
1124
1125 test qdel/qrm
1126
1127 $ hg qdel baz
1128 $ echo p >> .hg/patches/series
1129 $ hg qrm p
1130 $ hg qser
1131 bar
1132
1133 create a git patch
1134
1135 $ echo a > alexander
1136 $ hg add alexander
1137 $ hg qnew -f --git addalexander
1138 $ grep diff .hg/patches/addalexander
1139 diff --git a/alexander b/alexander
1140
1141
1142 create a git binary patch
1143
1144 $ cat > writebin.py <<EOF
1145 > import sys
1146 > path = sys.argv[1]
1147 > open(path, 'wb').write(b'BIN\x00ARY')
1148 > EOF
1149 $ "$PYTHON" writebin.py bucephalus
1150
1151 $ "$PYTHON" "$TESTDIR/md5sum.py" bucephalus
1152 8ba2a2f3e77b55d03051ff9c24ad65e7 bucephalus
1153 $ hg add bucephalus
1154 $ hg qnew -f --git addbucephalus
1155 $ grep diff .hg/patches/addbucephalus
1156 diff --git a/bucephalus b/bucephalus
1157
1158
1159 check binary patches can be popped and pushed
1160
1161 $ hg qpop
1162 popping addbucephalus
1163 now at: addalexander
1164 $ test -f bucephalus && echo % bucephalus should not be there
1165 [1]
1166 $ hg qpush
1167 applying addbucephalus
1168 now at: addbucephalus
1169 $ test -f bucephalus
1170 $ "$PYTHON" "$TESTDIR/md5sum.py" bucephalus
1171 8ba2a2f3e77b55d03051ff9c24ad65e7 bucephalus
1172
1173
1174
1175 strip again
1176
1177 $ cd ..
1178 $ hg init strip
1179 $ cd strip
1180 $ touch foo
1181 $ hg add foo
1182 $ hg ci -m 'add foo'
1183 $ echo >> foo
1184 $ hg ci -m 'change foo 1'
1185 $ hg up -C 0
1186 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1187 $ echo 1 >> foo
1188 $ hg ci -m 'change foo 2'
1189 created new head
1190 $ HGMERGE=true hg merge
1191 merging foo
1192 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
1193 (branch merge, don't forget to commit)
1194 $ hg ci -m merge
1195 $ hg log
1196 changeset: 3:99615015637b
1197 tag: tip
1198 parent: 2:20cbbe65cff7
1199 parent: 1:d2871fc282d4
1200 user: test
1201 date: Thu Jan 01 00:00:00 1970 +0000
1202 summary: merge
1203
1204 changeset: 2:20cbbe65cff7
1205 parent: 0:53245c60e682
1206 user: test
1207 date: Thu Jan 01 00:00:00 1970 +0000
1208 summary: change foo 2
1209
1210 changeset: 1:d2871fc282d4
1211 user: test
1212 date: Thu Jan 01 00:00:00 1970 +0000
1213 summary: change foo 1
1214
1215 changeset: 0:53245c60e682
1216 user: test
1217 date: Thu Jan 01 00:00:00 1970 +0000
1218 summary: add foo
1219
1220 $ hg strip 1
1221 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1222 saved backup bundle to $TESTTMP/strip/.hg/strip-backup/*-backup.hg (glob)
1223 $ checkundo strip
1224 $ hg log
1225 changeset: 1:20cbbe65cff7
1226 tag: tip
1227 user: test
1228 date: Thu Jan 01 00:00:00 1970 +0000
1229 summary: change foo 2
1230
1231 changeset: 0:53245c60e682
1232 user: test
1233 date: Thu Jan 01 00:00:00 1970 +0000
1234 summary: add foo
1235
1236 $ cd ..
1237
1238
1239 qclone
1240
1241 $ qlog()
1242 > {
1243 > echo 'main repo:'
1244 > hg log --template ' rev {rev}: {desc}\n'
1245 > echo 'patch repo:'
1246 > hg -R .hg/patches log --template ' rev {rev}: {desc}\n'
1247 > }
1248 $ hg init qclonesource
1249 $ cd qclonesource
1250 $ echo foo > foo
1251 $ hg add foo
1252 $ hg ci -m 'add foo'
1253 $ hg qinit
1254 $ hg qnew patch1
1255 $ echo bar >> foo
1256 $ hg qrefresh -m 'change foo'
1257 $ cd ..
1258
1259
1260 repo with unversioned patch dir
1261
1262 $ hg qclone qclonesource failure
1263 abort: versioned patch repository not found (see init --mq)
1264 [255]
1265
1266 $ cd qclonesource
1267 $ hg qinit -c
1268 adding .hg/patches/patch1
1269 $ hg qci -m checkpoint
1270 $ qlog
1271 main repo:
1272 rev 1: change foo
1273 rev 0: add foo
1274 patch repo:
1275 rev 0: checkpoint
1276 $ cd ..
1277
1278
1279 repo with patches applied
1280
1281 $ hg qclone qclonesource qclonedest
1282 updating to branch default
1283 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
1284 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1285 $ cd qclonedest
1286 $ qlog
1287 main repo:
1288 rev 0: add foo
1289 patch repo:
1290 rev 0: checkpoint
1291 $ cd ..
1292
1293
1294 repo with patches unapplied
1295
1296 $ cd qclonesource
1297 $ hg qpop -a
1298 popping patch1
1299 patch queue now empty
1300 $ qlog
1301 main repo:
1302 rev 0: add foo
1303 patch repo:
1304 rev 0: checkpoint
1305 $ cd ..
1306 $ hg qclone qclonesource qclonedest2
1307 updating to branch default
1308 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
1309 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1310 $ cd qclonedest2
1311 $ qlog
1312 main repo:
1313 rev 0: add foo
1314 patch repo:
1315 rev 0: checkpoint
1316 $ cd ..
1317
1318
1319 Issue1033: test applying on an empty file
1320
1321 $ hg init empty
1322 $ cd empty
1323 $ touch a
1324 $ hg ci -Am addempty
1325 adding a
1326 $ echo a > a
1327 $ hg qnew -f -e changea
1328 $ hg qpop
1329 popping changea
1330 patch queue now empty
1331 $ hg qpush
1332 applying changea
1333 now at: changea
1334 $ cd ..
1335
1336 test qpush with --force, issue1087
1337
1338 $ hg init forcepush
1339 $ cd forcepush
1340 $ echo hello > hello.txt
1341 $ echo bye > bye.txt
1342 $ hg ci -Ama
1343 adding bye.txt
1344 adding hello.txt
1345 $ hg qnew -d '0 0' empty
1346 $ hg qpop
1347 popping empty
1348 patch queue now empty
1349 $ echo world >> hello.txt
1350
1351
1352 qpush should fail, local changes
1353
1354 $ hg qpush
1355 abort: local changes found
1356 [255]
1357
1358
1359 apply force, should not discard changes with empty patch
1360
1361 $ hg qpush -f
1362 applying empty
1363 patch empty is empty
1364 now at: empty
1365 $ hg diff --config diff.nodates=True
1366 diff -r d58265112590 hello.txt
1367 --- a/hello.txt
1368 +++ b/hello.txt
1369 @@ -1,1 +1,2 @@
1370 hello
1371 +world
1372 $ hg qdiff --config diff.nodates=True
1373 diff -r 9ecee4f634e3 hello.txt
1374 --- a/hello.txt
1375 +++ b/hello.txt
1376 @@ -1,1 +1,2 @@
1377 hello
1378 +world
1379 $ hg log -l1 -p
1380 changeset: 1:d58265112590
1381 tag: empty
1382 tag: qbase
1383 tag: qtip
1384 tag: tip
1385 user: test
1386 date: Thu Jan 01 00:00:00 1970 +0000
1387 summary: imported patch empty
1388
1389
1390 $ hg qref -d '0 0'
1391 $ hg qpop
1392 popping empty
1393 patch queue now empty
1394 $ echo universe >> hello.txt
1395 $ echo universe >> bye.txt
1396
1397
1398 qpush should fail, local changes
1399
1400 $ hg qpush
1401 abort: local changes found
1402 [255]
1403
1404
1405 apply force, should discard changes in hello, but not bye
1406
1407 $ hg qpush -f --verbose --config 'ui.origbackuppath=.hg/origbackups'
1408 applying empty
1409 creating directory: $TESTTMP/forcepush/.hg/origbackups
1410 saving current version of hello.txt as .hg/origbackups/hello.txt
1411 patching file hello.txt
1412 committing files:
1413 hello.txt
1414 committing manifest
1415 committing changelog
1416 now at: empty
1417 $ hg st
1418 M bye.txt
1419 $ hg diff --config diff.nodates=True
1420 diff -r ba252371dbc1 bye.txt
1421 --- a/bye.txt
1422 +++ b/bye.txt
1423 @@ -1,1 +1,2 @@
1424 bye
1425 +universe
1426 $ hg qdiff --config diff.nodates=True
1427 diff -r 9ecee4f634e3 bye.txt
1428 --- a/bye.txt
1429 +++ b/bye.txt
1430 @@ -1,1 +1,2 @@
1431 bye
1432 +universe
1433 diff -r 9ecee4f634e3 hello.txt
1434 --- a/hello.txt
1435 +++ b/hello.txt
1436 @@ -1,1 +1,3 @@
1437 hello
1438 +world
1439 +universe
1440
1441 test that the previous call to qpush with -f (--force) and --config actually put
1442 the orig files out of the working copy
1443 $ ls .hg/origbackups
1444 hello.txt
1445
1446 test popping revisions not in working dir ancestry
1447
1448 $ hg qseries -v
1449 0 A empty
1450 $ hg up qparent
1451 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1452 $ hg qpop
1453 popping empty
1454 patch queue now empty
1455
1456 $ cd ..
1457 $ hg init deletion-order
1458 $ cd deletion-order
1459
1460 $ touch a
1461 $ hg ci -Aqm0
1462
1463 $ hg qnew rename-dir
1464 $ hg rm a
1465 $ hg qrefresh
1466
1467 $ mkdir a b
1468 $ touch a/a b/b
1469 $ hg add -q a b
1470 $ hg qrefresh
1471
1472
1473 test popping must remove files added in subdirectories first
1474
1475 $ hg qpop
1476 popping rename-dir
1477 patch queue now empty
1478 $ cd ..
1479
1480
1481 test case preservation through patch pushing especially on case
1482 insensitive filesystem
1483
1484 $ hg init casepreserve
1485 $ cd casepreserve
1486
1487 $ hg qnew add-file1
1488 $ echo a > TeXtFiLe.TxT
1489 $ hg add TeXtFiLe.TxT
1490 $ hg qrefresh
1491
1492 $ hg qnew add-file2
1493 $ echo b > AnOtHeRFiLe.TxT
1494 $ hg add AnOtHeRFiLe.TxT
1495 $ hg qrefresh
1496
1497 $ hg qnew modify-file
1498 $ echo c >> AnOtHeRFiLe.TxT
1499 $ hg qrefresh
1500
1501 $ hg qapplied
1502 add-file1
1503 add-file2
1504 modify-file
1505 $ hg qpop -a
1506 popping modify-file
1507 popping add-file2
1508 popping add-file1
1509 patch queue now empty
1510
1511 this qpush causes problems below, if case preservation on case
1512 insensitive filesystem is not enough:
1513 (1) unexpected "adding ..." messages are shown
1514 (2) patching fails in modification of (1) files
1515
1516 $ hg qpush -a
1517 applying add-file1
1518 applying add-file2
1519 applying modify-file
1520 now at: modify-file
1521
1522 Proper phase default with mq:
1523
1524 1. mq.secret=false
1525
1526 $ rm .hg/store/phaseroots
1527 $ hg phase 'qparent::'
1528 -1: public
1529 0: draft
1530 1: draft
1531 2: draft
1532 $ echo '[mq]' >> $HGRCPATH
1533 $ echo 'secret=true' >> $HGRCPATH
1534 $ rm -f .hg/store/phaseroots
1535 $ hg phase 'qparent::'
1536 -1: public
1537 0: secret
1538 1: secret
1539 2: secret
1540
1541 Test that qfinish change phase when mq.secret=true
1542
1543 $ hg qfinish qbase
1544 patch add-file1 finalized without changeset message
1545 $ hg phase 'all()'
1546 0: draft
1547 1: secret
1548 2: secret
1549
1550 Test that qfinish respect phases.new-commit setting
1551
1552 $ echo '[phases]' >> $HGRCPATH
1553 $ echo 'new-commit=secret' >> $HGRCPATH
1554 $ hg qfinish qbase
1555 patch add-file2 finalized without changeset message
1556 $ hg phase 'all()'
1557 0: draft
1558 1: secret
1559 2: secret
1560
1561 (restore env for next test)
1562
1563 $ sed -e 's/new-commit=secret//' $HGRCPATH > $TESTTMP/sedtmp
1564 $ cp $TESTTMP/sedtmp $HGRCPATH
1565 $ hg qimport -r 1 --name add-file2
1566
1567 Test that qfinish preserve phase when mq.secret=false
1568
1569 $ sed -e 's/secret=true/secret=false/' $HGRCPATH > $TESTTMP/sedtmp
1570 $ cp $TESTTMP/sedtmp $HGRCPATH
1571 $ hg qfinish qbase
1572 patch add-file2 finalized without changeset message
1573 $ hg phase 'all()'
1574 0: draft
1575 1: secret
1576 2: secret
1577
1578 Test that secret mq patch does not break hgweb
1579
1580 $ cat > hgweb.cgi <<HGWEB
1581 > from mercurial import demandimport; demandimport.enable()
1582 > from mercurial.hgweb import hgweb
1583 > from mercurial.hgweb import wsgicgi
1584 > app = hgweb(b'.', b'test')
1585 > wsgicgi.launch(app)
1586 > HGWEB
1587 $ . "$TESTDIR/cgienv"
1588 #if msys
1589 $ PATH_INFO=//tags; export PATH_INFO
1590 #else
1591 $ PATH_INFO=/tags; export PATH_INFO
1592 #endif
1593 $ QUERY_STRING='style=raw'
1594 $ "$PYTHON" hgweb.cgi | grep '^tip'
1595 tip [0-9a-f]{40} (re)
1596
1597 $ cd ..
1598
1599 Test interaction with revset (issue4426)
1600
1601 $ hg init issue4426
1602 $ cd issue4426
1603
1604 $ echo a > a
1605 $ hg ci -Am a
1606 adding a
1607 $ echo a >> a
1608 $ hg ci -m a
1609 $ echo a >> a
1610 $ hg ci -m a
1611 $ hg qimport -r 0::
1612
1613 reimport things
1614
1615 $ hg qimport -r 1::
1616 abort: revision 2 is already managed
1617 [255]
1618
1619
1620 $ cd ..