1 #!/bin/sh |
|
2 |
|
3 . $TESTDIR/helpers.sh |
|
4 |
|
5 checkundo() |
|
6 { |
|
7 if [ -f .hg/store/undo ]; then |
|
8 echo ".hg/store/undo still exists after $1" |
|
9 fi |
|
10 } |
|
11 |
|
12 echo "[extensions]" >> $HGRCPATH |
|
13 echo "mq=" >> $HGRCPATH |
|
14 |
|
15 echo "[mq]" >> $HGRCPATH |
|
16 echo "plain=true" >> $HGRCPATH |
|
17 |
|
18 echo % help |
|
19 hg help mq |
|
20 |
|
21 hg init a |
|
22 cd a |
|
23 echo a > a |
|
24 hg ci -Ama |
|
25 |
|
26 hg clone . ../k |
|
27 |
|
28 mkdir b |
|
29 echo z > b/z |
|
30 hg ci -Ama |
|
31 |
|
32 echo % qinit |
|
33 |
|
34 hg qinit |
|
35 |
|
36 cd .. |
|
37 hg init b |
|
38 |
|
39 echo % -R qinit |
|
40 |
|
41 hg -R b qinit |
|
42 |
|
43 hg init c |
|
44 |
|
45 echo % qinit -c |
|
46 |
|
47 hg --cwd c qinit -c |
|
48 hg -R c/.hg/patches st |
|
49 |
|
50 echo '% qinit; qinit -c' |
|
51 hg init d |
|
52 cd d |
|
53 hg qinit |
|
54 hg qinit -c |
|
55 # qinit -c should create both files if they don't exist |
|
56 echo ' .hgignore:' |
|
57 cat .hg/patches/.hgignore |
|
58 echo ' series:' |
|
59 cat .hg/patches/series |
|
60 hg qinit -c 2>&1 | sed -e 's/repository.*already/repository already/' |
|
61 cd .. |
|
62 |
|
63 echo '% qinit; <stuff>; qinit -c' |
|
64 hg init e |
|
65 cd e |
|
66 hg qnew A |
|
67 checkundo qnew |
|
68 echo foo > foo |
|
69 hg add foo |
|
70 hg qrefresh |
|
71 hg qnew B |
|
72 echo >> foo |
|
73 hg qrefresh |
|
74 echo status >> .hg/patches/.hgignore |
|
75 echo bleh >> .hg/patches/.hgignore |
|
76 hg qinit -c |
|
77 hg -R .hg/patches status |
|
78 # qinit -c shouldn't touch these files if they already exist |
|
79 echo ' .hgignore:' |
|
80 cat .hg/patches/.hgignore |
|
81 echo ' series:' |
|
82 cat .hg/patches/series |
|
83 |
|
84 echo '% status --mq with color (issue2096)' |
|
85 hg status --mq --config extensions.color= --color=always |
|
86 cd .. |
|
87 |
|
88 echo '% init --mq without repo' |
|
89 mkdir f |
|
90 cd f |
|
91 hg init --mq |
|
92 cd .. |
|
93 |
|
94 echo '% init --mq with repo path' |
|
95 hg init g |
|
96 hg init --mq g |
|
97 test -d g/.hg/patches/.hg && echo "ok" || echo "failed" |
|
98 |
|
99 echo '% init --mq with nonexistent directory' |
|
100 hg init --mq nonexistentdir |
|
101 |
|
102 echo '% init --mq with bundle (non "local")' |
|
103 hg -R a bundle --all a.bundle >/dev/null |
|
104 hg init --mq a.bundle |
|
105 |
|
106 cd a |
|
107 |
|
108 hg qnew -m 'foo bar' test.patch |
|
109 |
|
110 echo '# comment' > .hg/patches/series.tmp |
|
111 echo >> .hg/patches/series.tmp # empty line |
|
112 cat .hg/patches/series >> .hg/patches/series.tmp |
|
113 mv .hg/patches/series.tmp .hg/patches/series |
|
114 |
|
115 echo % qrefresh |
|
116 |
|
117 echo a >> a |
|
118 hg qrefresh |
|
119 sed -e "s/^\(diff -r \)\([a-f0-9]* \)/\1 x/" \ |
|
120 -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ |
|
121 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" .hg/patches/test.patch |
|
122 |
|
123 echo % empty qrefresh |
|
124 |
|
125 hg qrefresh -X a |
|
126 echo 'revision:' |
|
127 hg diff -r -2 -r -1 |
|
128 echo 'patch:' |
|
129 cat .hg/patches/test.patch |
|
130 echo 'working dir diff:' |
|
131 hg diff --nodates -q |
|
132 # restore things |
|
133 hg qrefresh |
|
134 checkundo qrefresh |
|
135 |
|
136 echo % qpop |
|
137 |
|
138 hg qpop |
|
139 checkundo qpop |
|
140 |
|
141 echo % qpush with dump of tag cache |
|
142 |
|
143 # Dump the tag cache to ensure that it has exactly one head after qpush. |
|
144 rm -f .hg/tags.cache |
|
145 hg tags > /dev/null |
|
146 echo ".hg/tags.cache (pre qpush):" |
|
147 sed 's/ [0-9a-f]*//' .hg/tags.cache |
|
148 hg qpush |
|
149 hg tags > /dev/null |
|
150 echo ".hg/tags.cache (post qpush):" |
|
151 sed 's/ [0-9a-f]*//' .hg/tags.cache |
|
152 |
|
153 checkundo qpush |
|
154 |
|
155 cd .. |
|
156 |
|
157 echo % pop/push outside repo |
|
158 |
|
159 hg -R a qpop |
|
160 hg -R a qpush |
|
161 |
|
162 cd a |
|
163 hg qnew test2.patch |
|
164 |
|
165 echo % qrefresh in subdir |
|
166 |
|
167 cd b |
|
168 echo a > a |
|
169 hg add a |
|
170 hg qrefresh |
|
171 |
|
172 echo % pop/push -a in subdir |
|
173 |
|
174 hg qpop -a |
|
175 hg --traceback qpush -a |
|
176 |
|
177 # setting columns & formatted tests truncating (issue1912) |
|
178 echo % qseries |
|
179 COLUMNS=4 hg qseries --config ui.formatted=true |
|
180 COLUMNS=20 hg qseries --config ui.formatted=true -vs |
|
181 hg qpop |
|
182 hg qseries -vs |
|
183 hg sum | grep mq |
|
184 hg qpush |
|
185 hg sum | grep mq |
|
186 |
|
187 echo % qapplied |
|
188 hg qapplied |
|
189 |
|
190 echo % qtop |
|
191 hg qtop |
|
192 |
|
193 echo % prev |
|
194 hg qapp -1 |
|
195 |
|
196 echo % next |
|
197 hg qunapp -1 |
|
198 |
|
199 hg qpop |
|
200 echo % commit should fail |
|
201 hg commit |
|
202 |
|
203 echo % push should fail |
|
204 hg push ../../k |
|
205 |
|
206 echo % import should fail |
|
207 hg st . |
|
208 echo foo >> ../a |
|
209 hg diff > ../../import.diff |
|
210 hg revert --no-backup ../a |
|
211 hg import ../../import.diff |
|
212 hg st |
|
213 echo % import --no-commit should succeed |
|
214 hg import --no-commit ../../import.diff |
|
215 hg st |
|
216 hg revert --no-backup ../a |
|
217 |
|
218 echo % qunapplied |
|
219 hg qunapplied |
|
220 |
|
221 echo % qpush/qpop with index |
|
222 hg qnew test1b.patch |
|
223 echo 1b > 1b |
|
224 hg add 1b |
|
225 hg qrefresh |
|
226 hg qpush 2 |
|
227 hg qpop 0 |
|
228 hg qpush test.patch+1 |
|
229 hg qpush test.patch+2 |
|
230 hg qpop test2.patch-1 |
|
231 hg qpop test2.patch-2 |
|
232 hg qpush test1b.patch+1 |
|
233 |
|
234 echo % qpush --move |
|
235 hg qpop -a |
|
236 hg qguard test1b.patch -- -negguard |
|
237 hg qguard test2.patch -- +posguard |
|
238 hg qpush --move test2.patch # can't move guarded patch |
|
239 hg qselect posguard |
|
240 hg qpush --move test2.patch # move to front |
|
241 hg qpush --move test1b.patch # negative guard unselected |
|
242 hg qpush --move test.patch # noop move |
|
243 hg qseries -v |
|
244 hg qpop -a |
|
245 # cleaning up |
|
246 hg qselect --none |
|
247 hg qguard --none test1b.patch |
|
248 hg qguard --none test2.patch |
|
249 hg qpush --move test.patch |
|
250 hg qpush --move test1b.patch |
|
251 hg qpush --move bogus # nonexistent patch |
|
252 hg qpush --move # no patch |
|
253 hg qpush --move test.patch # already applied |
|
254 hg qpush |
|
255 |
|
256 echo % series after move |
|
257 cat `hg root`/.hg/patches/series |
|
258 |
|
259 echo % pop, qapplied, qunapplied |
|
260 hg qseries -v |
|
261 echo % qapplied -1 test.patch |
|
262 hg qapplied -1 test.patch |
|
263 echo % qapplied -1 test1b.patch |
|
264 hg qapplied -1 test1b.patch |
|
265 echo % qapplied -1 test2.patch |
|
266 hg qapplied -1 test2.patch |
|
267 echo % qapplied -1 |
|
268 hg qapplied -1 |
|
269 echo % qapplied |
|
270 hg qapplied |
|
271 echo % qapplied test1b.patch |
|
272 hg qapplied test1b.patch |
|
273 echo % qunapplied -1 |
|
274 hg qunapplied -1 |
|
275 echo % qunapplied |
|
276 hg qunapplied |
|
277 echo % popping |
|
278 hg qpop |
|
279 echo % qunapplied -1 |
|
280 hg qunapplied -1 |
|
281 echo % qunapplied |
|
282 hg qunapplied |
|
283 echo % qunapplied test2.patch |
|
284 hg qunapplied test2.patch |
|
285 echo % qunapplied -1 test2.patch |
|
286 hg qunapplied -1 test2.patch |
|
287 echo % popping -a |
|
288 hg qpop -a |
|
289 echo % qapplied |
|
290 hg qapplied |
|
291 echo % qapplied -1 |
|
292 hg qapplied -1 |
|
293 hg qpush |
|
294 |
|
295 echo % push should succeed |
|
296 hg qpop -a |
|
297 hg push ../../k |
|
298 |
|
299 echo % qpush/qpop error codes |
|
300 errorcode() |
|
301 { |
|
302 hg "$@" && echo " $@ succeeds" || echo " $@ fails" |
|
303 } |
|
304 |
|
305 # we want to start with some patches applied |
|
306 hg qpush -a |
|
307 echo " % pops all patches and succeeds" |
|
308 errorcode qpop -a |
|
309 echo " % does nothing and succeeds" |
|
310 errorcode qpop -a |
|
311 echo " % fails - nothing else to pop" |
|
312 errorcode qpop |
|
313 echo " % pushes a patch and succeeds" |
|
314 errorcode qpush |
|
315 echo " % pops a patch and succeeds" |
|
316 errorcode qpop |
|
317 echo " % pushes up to test1b.patch and succeeds" |
|
318 errorcode qpush test1b.patch |
|
319 echo " % does nothing and succeeds" |
|
320 errorcode qpush test1b.patch |
|
321 echo " % does nothing and succeeds" |
|
322 errorcode qpop test1b.patch |
|
323 echo " % fails - can't push to this patch" |
|
324 errorcode qpush test.patch |
|
325 echo " % fails - can't pop to this patch" |
|
326 errorcode qpop test2.patch |
|
327 echo " % pops up to test.patch and succeeds" |
|
328 errorcode qpop test.patch |
|
329 echo " % pushes all patches and succeeds" |
|
330 errorcode qpush -a |
|
331 echo " % does nothing and succeeds" |
|
332 errorcode qpush -a |
|
333 echo " % fails - nothing else to push" |
|
334 errorcode qpush |
|
335 echo " % does nothing and succeeds" |
|
336 errorcode qpush test2.patch |
|
337 |
|
338 |
|
339 echo % strip |
|
340 cd ../../b |
|
341 echo x>x |
|
342 hg ci -Ama |
|
343 hg strip tip | hidebackup |
|
344 hg unbundle .hg/strip-backup/* |
|
345 |
|
346 echo % strip with local changes, should complain |
|
347 hg up |
|
348 echo y>y |
|
349 hg add y |
|
350 hg strip tip | hidebackup |
|
351 echo % --force strip with local changes |
|
352 hg strip -f tip | hidebackup |
|
353 |
|
354 echo '% cd b; hg qrefresh' |
|
355 hg init refresh |
|
356 cd refresh |
|
357 echo a > a |
|
358 hg ci -Ama |
|
359 hg qnew -mfoo foo |
|
360 echo a >> a |
|
361 hg qrefresh |
|
362 mkdir b |
|
363 cd b |
|
364 echo f > f |
|
365 hg add f |
|
366 hg qrefresh |
|
367 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ |
|
368 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" ../.hg/patches/foo |
|
369 echo % hg qrefresh . |
|
370 hg qrefresh . |
|
371 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ |
|
372 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" ../.hg/patches/foo |
|
373 hg status |
|
374 |
|
375 echo % qpush failure |
|
376 cd .. |
|
377 hg qrefresh |
|
378 hg qnew -mbar bar |
|
379 echo foo > foo |
|
380 echo bar > bar |
|
381 hg add foo bar |
|
382 hg qrefresh |
|
383 hg qpop -a |
|
384 echo bar > foo |
|
385 hg qpush -a |
|
386 hg st |
|
387 |
|
388 echo % mq tags |
|
389 hg log --template '{rev} {tags}\n' -r qparent:qtip |
|
390 |
|
391 echo % bad node in status |
|
392 hg qpop |
|
393 hg strip -qn tip |
|
394 hg tip 2>&1 | sed -e 's/unknown node .*/unknown node/' |
|
395 hg branches 2>&1 | sed -e 's/unknown node .*/unknown node/' |
|
396 hg qpop 2>&1 | sed -e 's/unknown node .*/unknown node/' |
|
397 |
|
398 cat >>$HGRCPATH <<EOF |
|
399 [diff] |
|
400 git = True |
|
401 EOF |
|
402 cd .. |
|
403 hg init git |
|
404 cd git |
|
405 hg qinit |
|
406 |
|
407 hg qnew -m'new file' new |
|
408 echo foo > new |
|
409 chmod +x new |
|
410 hg add new |
|
411 hg qrefresh |
|
412 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ |
|
413 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" .hg/patches/new |
|
414 |
|
415 hg qnew -m'copy file' copy |
|
416 hg cp new copy |
|
417 hg qrefresh |
|
418 sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ |
|
419 -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" .hg/patches/copy |
|
420 |
|
421 hg qpop |
|
422 hg qpush |
|
423 hg qdiff |
|
424 cat >>$HGRCPATH <<EOF |
|
425 [diff] |
|
426 git = False |
|
427 EOF |
|
428 hg qdiff --git |
|
429 cd .. |
|
430 |
|
431 echo % test file addition in slow path |
|
432 hg init slow |
|
433 cd slow |
|
434 hg qinit |
|
435 echo foo > foo |
|
436 hg add foo |
|
437 hg ci -m 'add foo' |
|
438 hg qnew bar |
|
439 echo bar > bar |
|
440 hg add bar |
|
441 hg mv foo baz |
|
442 hg qrefresh --git |
|
443 hg up -C 0 |
|
444 echo >> foo |
|
445 hg ci -m 'change foo' |
|
446 hg up -C 1 |
|
447 hg qrefresh --git 2>&1 | grep -v 'saving bundle' |
|
448 cat .hg/patches/bar |
|
449 hg log -v --template '{rev} {file_copies}\n' -r . |
|
450 hg qrefresh --git |
|
451 cat .hg/patches/bar |
|
452 hg log -v --template '{rev} {file_copies}\n' -r . |
|
453 hg qrefresh |
|
454 grep 'diff --git' .hg/patches/bar |
|
455 |
|
456 echo % test file move chains in the slow path |
|
457 hg up -C 1 |
|
458 echo >> foo |
|
459 hg ci -m 'change foo again' |
|
460 hg up -C 2 |
|
461 hg mv bar quux |
|
462 hg mv baz bleh |
|
463 hg qrefresh --git 2>&1 | grep -v 'saving bundle' |
|
464 cat .hg/patches/bar |
|
465 hg log -v --template '{rev} {file_copies}\n' -r . |
|
466 hg mv quux fred |
|
467 hg mv bleh barney |
|
468 hg qrefresh --git |
|
469 cat .hg/patches/bar |
|
470 hg log -v --template '{rev} {file_copies}\n' -r . |
|
471 |
|
472 echo % refresh omitting an added file |
|
473 hg qnew baz |
|
474 echo newfile > newfile |
|
475 hg add newfile |
|
476 hg qrefresh |
|
477 hg st -A newfile |
|
478 hg qrefresh -X newfile |
|
479 hg st -A newfile |
|
480 hg revert newfile |
|
481 rm newfile |
|
482 hg qpop |
|
483 hg qdel baz |
|
484 |
|
485 echo % create a git patch |
|
486 echo a > alexander |
|
487 hg add alexander |
|
488 hg qnew -f --git addalexander |
|
489 grep diff .hg/patches/addalexander |
|
490 |
|
491 echo % create a git binary patch |
|
492 cat > writebin.py <<EOF |
|
493 import sys |
|
494 path = sys.argv[1] |
|
495 open(path, 'wb').write('BIN\x00ARY') |
|
496 EOF |
|
497 python writebin.py bucephalus |
|
498 |
|
499 python "$TESTDIR/md5sum.py" bucephalus |
|
500 hg add bucephalus |
|
501 hg qnew -f --git addbucephalus |
|
502 grep diff .hg/patches/addbucephalus |
|
503 |
|
504 echo % check binary patches can be popped and pushed |
|
505 hg qpop |
|
506 test -f bucephalus && echo % bucephalus should not be there |
|
507 hg qpush |
|
508 test -f bucephalus || echo % bucephalus should be there |
|
509 python "$TESTDIR/md5sum.py" bucephalus |
|
510 |
|
511 |
|
512 echo '% strip again' |
|
513 cd .. |
|
514 hg init strip |
|
515 cd strip |
|
516 touch foo |
|
517 hg add foo |
|
518 hg ci -m 'add foo' |
|
519 echo >> foo |
|
520 hg ci -m 'change foo 1' |
|
521 hg up -C 0 |
|
522 echo 1 >> foo |
|
523 hg ci -m 'change foo 2' |
|
524 HGMERGE=true hg merge |
|
525 hg ci -m merge |
|
526 hg log |
|
527 hg strip 1 | hidebackup |
|
528 checkundo strip |
|
529 hg log |
|
530 cd .. |
|
531 |
|
532 echo '% qclone' |
|
533 qlog() |
|
534 { |
|
535 echo 'main repo:' |
|
536 hg log --template ' rev {rev}: {desc}\n' |
|
537 echo 'patch repo:' |
|
538 hg -R .hg/patches log --template ' rev {rev}: {desc}\n' |
|
539 } |
|
540 hg init qclonesource |
|
541 cd qclonesource |
|
542 echo foo > foo |
|
543 hg add foo |
|
544 hg ci -m 'add foo' |
|
545 hg qinit |
|
546 hg qnew patch1 |
|
547 echo bar >> foo |
|
548 hg qrefresh -m 'change foo' |
|
549 cd .. |
|
550 |
|
551 # repo with unversioned patch dir |
|
552 hg qclone qclonesource failure |
|
553 |
|
554 cd qclonesource |
|
555 hg qinit -c |
|
556 hg qci -m checkpoint |
|
557 qlog |
|
558 cd .. |
|
559 |
|
560 # repo with patches applied |
|
561 hg qclone qclonesource qclonedest |
|
562 cd qclonedest |
|
563 qlog |
|
564 cd .. |
|
565 |
|
566 # repo with patches unapplied |
|
567 cd qclonesource |
|
568 hg qpop -a |
|
569 qlog |
|
570 cd .. |
|
571 hg qclone qclonesource qclonedest2 |
|
572 cd qclonedest2 |
|
573 qlog |
|
574 cd .. |
|
575 |
|
576 echo % 'test applying on an empty file (issue 1033)' |
|
577 hg init empty |
|
578 cd empty |
|
579 touch a |
|
580 hg ci -Am addempty |
|
581 echo a > a |
|
582 hg qnew -f -e changea |
|
583 hg qpop |
|
584 hg qpush |
|
585 cd .. |
|
586 |
|
587 echo % test qpush with --force, issue1087 |
|
588 hg init forcepush |
|
589 cd forcepush |
|
590 echo hello > hello.txt |
|
591 echo bye > bye.txt |
|
592 hg ci -Ama |
|
593 hg qnew -d '0 0' empty |
|
594 hg qpop |
|
595 echo world >> hello.txt |
|
596 |
|
597 echo % qpush should fail, local changes |
|
598 hg qpush |
|
599 |
|
600 echo % apply force, should not discard changes with empty patch |
|
601 hg qpush -f 2>&1 | sed 's,^.*/patch,patch,g' |
|
602 hg diff --config diff.nodates=True |
|
603 hg qdiff --config diff.nodates=True |
|
604 hg log -l1 -p |
|
605 hg qref -d '0 0' |
|
606 hg qpop |
|
607 echo universe >> hello.txt |
|
608 echo universe >> bye.txt |
|
609 |
|
610 echo % qpush should fail, local changes |
|
611 hg qpush |
|
612 |
|
613 echo % apply force, should discard changes in hello, but not bye |
|
614 hg qpush -f |
|
615 hg st |
|
616 hg diff --config diff.nodates=True |
|
617 hg qdiff --config diff.nodates=True |
|
618 |
|
619 echo % test popping revisions not in working dir ancestry |
|
620 hg qseries -v |
|
621 hg up qparent |
|
622 hg qpop |
|
623 |
|
624 cd .. |
|
625 hg init deletion-order |
|
626 cd deletion-order |
|
627 |
|
628 touch a |
|
629 hg ci -Aqm0 |
|
630 |
|
631 hg qnew rename-dir |
|
632 hg rm a |
|
633 hg qrefresh |
|
634 |
|
635 mkdir a b |
|
636 touch a/a b/b |
|
637 hg add -q a b |
|
638 hg qrefresh |
|
639 |
|
640 echo % test popping must remove files added in subdirectories first |
|
641 hg qpop |
|
642 cd .. |
|