]> git.ipfire.org Git - thirdparty/git.git/blame - contrib/remote-helpers/test-hg.sh
Merge branch 'jc/graduate-remote-hg-bzr' (early part)
[thirdparty/git.git] / contrib / remote-helpers / test-hg.sh
CommitLineData
7ee719e1
FC
1#!/bin/sh
2#
3# Copyright (c) 2012 Felipe Contreras
4#
5# Base commands from hg-git tests:
6# https://bitbucket.org/durin42/hg-git/src
7#
8
9test_description='Test remote-hg'
10
d3243d73
FC
11test -n "$TEST_DIRECTORY" || TEST_DIRECTORY=${0%/*}/../../t
12. "$TEST_DIRECTORY"/test-lib.sh
7ee719e1 13
ff867963
JH
14if ! test_have_prereq PYTHON
15then
7ee719e1
FC
16 skip_all='skipping remote-hg tests; python not available'
17 test_done
18fi
19
ff867963
JH
20if ! python -c 'import mercurial'
21then
7ee719e1
FC
22 skip_all='skipping remote-hg tests; mercurial not available'
23 test_done
24fi
25
26check () {
ff867963
JH
27 echo $3 >expected &&
28 git --git-dir=$1/.git log --format='%s' -1 $2 >actual
7ee719e1
FC
29 test_cmp expected actual
30}
31
9f36d61e 32check_branch () {
ff867963
JH
33 if test -n "$3"
34 then
35 echo $3 >expected &&
36 hg -R $1 log -r $2 --template '{desc}\n' >actual &&
d2c76330
FC
37 test_cmp expected actual
38 else
ff867963 39 hg -R $1 branches >out &&
d2c76330
FC
40 ! grep $2 out
41 fi
9f36d61e
FC
42}
43
b082b4f9 44check_bookmark () {
ff867963
JH
45 if test -n "$3"
46 then
47 echo $3 >expected &&
48 hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' >actual &&
d2c76330
FC
49 test_cmp expected actual
50 else
ff867963 51 hg -R $1 bookmarks >out &&
d2c76330
FC
52 ! grep $2 out
53 fi
b082b4f9
FC
54}
55
42cbbcc7 56check_push () {
5105edd4 57 expected_ret=$1 ret=0 ref_ret=0
42cbbcc7
FC
58
59 shift
ff867963 60 git push origin "$@" 2>error
42cbbcc7
FC
61 ret=$?
62 cat error
63
5105edd4 64 while IFS=':' read branch kind
42cbbcc7
FC
65 do
66 case "$kind" in
67 'new')
68 grep "^ \* \[new branch\] *${branch} -> ${branch}$" error || ref_ret=1
69 ;;
70 'non-fast-forward')
71 grep "^ ! \[rejected\] *${branch} -> ${branch} (non-fast-forward)$" error || ref_ret=1
72 ;;
ba091c20
FC
73 'fetch-first')
74 grep "^ ! \[rejected\] *${branch} -> ${branch} (fetch first)$" error || ref_ret=1
75 ;;
c9eaef12
FC
76 'forced-update')
77 grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *${branch} -> ${branch} (forced update)$" error || ref_ret=1
78 ;;
42cbbcc7
FC
79 '')
80 grep "^ [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
81 ;;
82 esac
2a698183 83 test $ref_ret -ne 0 && echo "match for '$branch' failed" && break
42cbbcc7
FC
84 done
85
25607db2 86 if test $expected_ret -ne $ret || test $ref_ret -ne 0
42cbbcc7
FC
87 then
88 return 1
89 fi
90
91 return 0
92}
93
7241a9ff
RR
94setup () {
95 (
96 echo "[ui]"
97 echo "username = H G Wells <wells@example.com>"
9529cce8
FC
98 echo "[extensions]"
99 echo "mq ="
ff867963 100 ) >>"$HOME"/.hgrc &&
9f36d61e
FC
101
102 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" &&
103 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" &&
104 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
7241a9ff
RR
105}
106
107setup
108
7ee719e1 109test_expect_success 'cloning' '
4080ac81
FC
110 test_when_finished "rm -rf gitrepo*" &&
111
112 (
113 hg init hgrepo &&
114 cd hgrepo &&
ff867963 115 echo zero >content &&
4080ac81
FC
116 hg add content &&
117 hg commit -m zero
118 ) &&
119
5f5e92fb 120 git clone "hg::hgrepo" gitrepo &&
91347ea3 121 check gitrepo HEAD zero
7ee719e1
FC
122'
123
124test_expect_success 'cloning with branches' '
4080ac81 125 test_when_finished "rm -rf gitrepo*" &&
7ee719e1 126
4080ac81
FC
127 (
128 cd hgrepo &&
129 hg branch next &&
ff867963 130 echo next >content &&
4080ac81
FC
131 hg commit -m next
132 ) &&
7ee719e1 133
5f5e92fb 134 git clone "hg::hgrepo" gitrepo &&
91347ea3 135 check gitrepo origin/branches/next next
7ee719e1
FC
136'
137
138test_expect_success 'cloning with bookmarks' '
4080ac81 139 test_when_finished "rm -rf gitrepo*" &&
7ee719e1 140
4080ac81
FC
141 (
142 cd hgrepo &&
91347ea3 143 hg checkout default &&
4080ac81 144 hg bookmark feature-a &&
ff867963 145 echo feature-a >content &&
4080ac81
FC
146 hg commit -m feature-a
147 ) &&
148
5f5e92fb 149 git clone "hg::hgrepo" gitrepo &&
91347ea3 150 check gitrepo origin/feature-a feature-a
7ee719e1
FC
151'
152
153test_expect_success 'update bookmark' '
4080ac81
FC
154 test_when_finished "rm -rf gitrepo*" &&
155
156 (
157 cd hgrepo &&
158 hg bookmark devel
159 ) &&
160
161 (
5f5e92fb 162 git clone "hg::hgrepo" gitrepo &&
4080ac81
FC
163 cd gitrepo &&
164 git checkout --quiet devel &&
ff867963 165 echo devel >content &&
4080ac81
FC
166 git commit -a -m devel &&
167 git push --quiet
168 ) &&
169
b082b4f9 170 check_bookmark hgrepo devel devel
7ee719e1
FC
171'
172
e14432f7
FC
173test_expect_success 'new bookmark' '
174 test_when_finished "rm -rf gitrepo*" &&
175
176 (
177 git clone "hg::hgrepo" gitrepo &&
178 cd gitrepo &&
179 git checkout --quiet -b feature-b &&
ff867963 180 echo feature-b >content &&
e14432f7
FC
181 git commit -a -m feature-b &&
182 git push --quiet origin feature-b
183 ) &&
184
185 check_bookmark hgrepo feature-b feature-b
186'
187
531594e5
FC
188# cleanup previous stuff
189rm -rf hgrepo
190
6181b9a6 191author_test () {
ff867963 192 echo $1 >>content &&
4080ac81 193 hg commit -u "$2" -m "add $1" &&
ff867963 194 echo "$3" >>../expected
6181b9a6
FC
195}
196
197test_expect_success 'authors' '
531594e5 198 test_when_finished "rm -rf hgrepo gitrepo" &&
4080ac81
FC
199
200 (
201 hg init hgrepo &&
202 cd hgrepo &&
203
204 touch content &&
205 hg add content &&
206
ff867963 207 >../expected &&
4080ac81 208 author_test alpha "" "H G Wells <wells@example.com>" &&
b2bff431
RH
209 author_test beta "beta" "beta <unknown>" &&
210 author_test gamma "gamma <test@example.com> (comment)" "gamma <test@example.com>" &&
211 author_test delta "<delta@example.com>" "Unknown <delta@example.com>" &&
212 author_test epsilon "epsilon<test@example.com>" "epsilon <test@example.com>" &&
213 author_test zeta "zeta <test@example.com" "zeta <test@example.com>" &&
214 author_test eta " eta " "eta <unknown>" &&
215 author_test theta "theta < test@example.com >" "theta <test@example.com>" &&
216 author_test iota "iota >test@example.com>" "iota <test@example.com>" &&
217 author_test kappa "kappa < test <at> example <dot> com>" "kappa <unknown>" &&
6c68a404
RH
218 author_test lambda "lambda@example.com" "Unknown <lambda@example.com>" &&
219 author_test mu "mu.mu@example.com" "Unknown <mu.mu@example.com>"
4080ac81
FC
220 ) &&
221
5f5e92fb 222 git clone "hg::hgrepo" gitrepo &&
ff867963 223 git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" >actual &&
4080ac81
FC
224
225 test_cmp expected actual
6181b9a6
FC
226'
227
9529cce8
FC
228test_expect_success 'strip' '
229 test_when_finished "rm -rf hgrepo gitrepo" &&
230
231 (
232 hg init hgrepo &&
233 cd hgrepo &&
234
ff867963 235 echo one >>content &&
9529cce8
FC
236 hg add content &&
237 hg commit -m one &&
238
ff867963 239 echo two >>content &&
9529cce8
FC
240 hg commit -m two
241 ) &&
242
243 git clone "hg::hgrepo" gitrepo &&
244
245 (
246 cd hgrepo &&
247 hg strip 1 &&
248
ff867963 249 echo three >>content &&
9529cce8
FC
250 hg commit -m three &&
251
ff867963 252 echo four >>content &&
9529cce8
FC
253 hg commit -m four
254 ) &&
255
256 (
257 cd gitrepo &&
258 git fetch &&
ff867963 259 git log --format="%s" origin/master >../actual
9529cce8
FC
260 ) &&
261
ff867963 262 hg -R hgrepo log --template "{desc}\n" >expected &&
9529cce8
FC
263 test_cmp actual expected
264'
265
9f36d61e
FC
266test_expect_success 'remote push with master bookmark' '
267 test_when_finished "rm -rf hgrepo gitrepo*" &&
268
269 (
270 hg init hgrepo &&
271 cd hgrepo &&
ff867963 272 echo zero >content &&
9f36d61e
FC
273 hg add content &&
274 hg commit -m zero &&
275 hg bookmark master &&
ff867963 276 echo one >content &&
9f36d61e
FC
277 hg commit -m one
278 ) &&
279
280 (
281 git clone "hg::hgrepo" gitrepo &&
282 cd gitrepo &&
ff867963 283 echo two >content &&
9f36d61e
FC
284 git commit -a -m two &&
285 git push
286 ) &&
287
288 check_branch hgrepo default two
289'
290
ff867963 291cat >expected <<\EOF
9f36d61e
FC
292changeset: 0:6e2126489d3d
293tag: tip
294user: A U Thor <author@example.com>
295date: Mon Jan 01 00:00:00 2007 +0230
296summary: one
297
298EOF
299
300test_expect_success 'remote push from master branch' '
301 test_when_finished "rm -rf hgrepo gitrepo*" &&
302
303 hg init hgrepo &&
304
305 (
306 git init gitrepo &&
307 cd gitrepo &&
308 git remote add origin "hg::../hgrepo" &&
ff867963 309 echo one >content &&
9f36d61e
FC
310 git add content &&
311 git commit -a -m one &&
312 git push origin master
313 ) &&
314
ff867963 315 hg -R hgrepo log >actual &&
9f36d61e
FC
316 cat actual &&
317 test_cmp expected actual &&
318
319 check_branch hgrepo default one
320'
321
e6e803be
FC
322GIT_REMOTE_HG_TEST_REMOTE=1
323export GIT_REMOTE_HG_TEST_REMOTE
324
325test_expect_success 'remote cloning' '
326 test_when_finished "rm -rf gitrepo*" &&
327
328 (
329 hg init hgrepo &&
330 cd hgrepo &&
ff867963 331 echo zero >content &&
e6e803be
FC
332 hg add content &&
333 hg commit -m zero
334 ) &&
335
336 git clone "hg::hgrepo" gitrepo &&
337 check gitrepo HEAD zero
338'
339
1f7feb77
AP
340test_expect_success 'moving remote clone' '
341 test_when_finished "rm -rf gitrepo*" &&
342
343 (
344 git clone "hg::hgrepo" gitrepo &&
345 mv gitrepo gitrepo2 &&
346 cd gitrepo2 &&
347 git fetch
348 )
349'
350
e6e803be
FC
351test_expect_success 'remote update bookmark' '
352 test_when_finished "rm -rf gitrepo*" &&
353
354 (
355 cd hgrepo &&
356 hg bookmark devel
357 ) &&
358
359 (
360 git clone "hg::hgrepo" gitrepo &&
361 cd gitrepo &&
362 git checkout --quiet devel &&
ff867963 363 echo devel >content &&
e6e803be
FC
364 git commit -a -m devel &&
365 git push --quiet
366 ) &&
367
368 check_bookmark hgrepo devel devel
369'
370
e14432f7
FC
371test_expect_success 'remote new bookmark' '
372 test_when_finished "rm -rf gitrepo*" &&
373
374 (
375 git clone "hg::hgrepo" gitrepo &&
376 cd gitrepo &&
377 git checkout --quiet -b feature-b &&
ff867963 378 echo feature-b >content &&
e14432f7
FC
379 git commit -a -m feature-b &&
380 git push --quiet origin feature-b
381 ) &&
382
383 check_bookmark hgrepo feature-b feature-b
384'
385
883d7be1 386test_expect_success 'remote push diverged' '
1a810864
FC
387 test_when_finished "rm -rf gitrepo*" &&
388
389 git clone "hg::hgrepo" gitrepo &&
390
391 (
392 cd hgrepo &&
393 hg checkout default &&
ff867963 394 echo bump >content &&
1a810864
FC
395 hg commit -m bump
396 ) &&
397
398 (
399 cd gitrepo &&
ff867963 400 echo diverge >content &&
1a810864 401 git commit -a -m diverged &&
ff867963 402 check_push 1 <<-\EOF
42cbbcc7
FC
403 master:non-fast-forward
404 EOF
1a810864
FC
405 ) &&
406
407 check_branch hgrepo default bump
408'
409
883d7be1 410test_expect_success 'remote update bookmark diverge' '
747b61c6
FC
411 test_when_finished "rm -rf gitrepo*" &&
412
413 (
414 cd hgrepo &&
415 hg checkout tip^ &&
416 hg bookmark diverge
417 ) &&
418
419 git clone "hg::hgrepo" gitrepo &&
420
421 (
422 cd hgrepo &&
ff867963 423 echo "bump bookmark" >content &&
747b61c6
FC
424 hg commit -m "bump bookmark"
425 ) &&
426
427 (
428 cd gitrepo &&
429 git checkout --quiet diverge &&
ff867963 430 echo diverge >content &&
747b61c6 431 git commit -a -m diverge &&
ff867963 432 check_push 1 <<-\EOF
ba091c20 433 diverge:fetch-first
42cbbcc7 434 EOF
747b61c6
FC
435 ) &&
436
437 check_bookmark hgrepo diverge "bump bookmark"
438'
439
d3c460b5 440test_expect_success 'remote new bookmark multiple branch head' '
ad22b92a
FC
441 test_when_finished "rm -rf gitrepo*" &&
442
443 (
444 git clone "hg::hgrepo" gitrepo &&
445 cd gitrepo &&
446 git checkout --quiet -b feature-c HEAD^ &&
ff867963 447 echo feature-c >content &&
ad22b92a
FC
448 git commit -a -m feature-c &&
449 git push --quiet origin feature-c
450 ) &&
451
452 check_bookmark hgrepo feature-c feature-c
453'
454
d2c76330
FC
455# cleanup previous stuff
456rm -rf hgrepo
457
8d784dae
FC
458test_expect_success 'fetch special filenames' '
459 test_when_finished "rm -rf hgrepo gitrepo && LC_ALL=C" &&
460
461 LC_ALL=en_US.UTF-8
462 export LC_ALL
463
464 (
465 hg init hgrepo &&
466 cd hgrepo &&
467
468 echo test >> "æ rø" &&
469 hg add "æ rø" &&
470 echo test >> "ø~?" &&
471 hg add "ø~?" &&
472 hg commit -m add-utf-8 &&
473 echo test >> "æ rø" &&
474 hg commit -m test-utf-8 &&
475 hg rm "ø~?" &&
476 hg mv "æ rø" "ø~?" &&
477 hg commit -m hg-mv-utf-8
478 ) &&
479
480 (
481 git clone "hg::hgrepo" gitrepo &&
482 cd gitrepo &&
483 git -c core.quotepath=false ls-files > ../actual
484 ) &&
485 echo "ø~?" > expected &&
486 test_cmp expected actual
487'
488
489test_expect_success 'push special filenames' '
490 test_when_finished "rm -rf hgrepo gitrepo && LC_ALL=C" &&
491
492 mkdir -p tmp && cd tmp &&
493
494 LC_ALL=en_US.UTF-8
495 export LC_ALL
496
497 (
498 hg init hgrepo &&
499 cd hgrepo &&
500
501 echo one >> content &&
502 hg add content &&
503 hg commit -m one
504 ) &&
505
506 (
507 git clone "hg::hgrepo" gitrepo &&
508 cd gitrepo &&
509
510 echo test >> "æ rø" &&
511 git add "æ rø" &&
512 git commit -m utf-8 &&
513
514 git push
515 ) &&
516
517 (cd hgrepo &&
518 hg update &&
519 hg manifest > ../actual
520 ) &&
521
522 printf "content\næ rø\n" > expected &&
523 test_cmp expected actual
524'
525
2b02a405 526setup_big_push () {
d2c76330
FC
527 (
528 hg init hgrepo &&
529 cd hgrepo &&
ff867963 530 echo zero >content &&
d2c76330
FC
531 hg add content &&
532 hg commit -m zero &&
533 hg bookmark bad_bmark1 &&
ff867963 534 echo one >content &&
d2c76330
FC
535 hg commit -m one &&
536 hg bookmark bad_bmark2 &&
537 hg bookmark good_bmark &&
538 hg bookmark -i good_bmark &&
539 hg -q branch good_branch &&
ff867963 540 echo "good branch" >content &&
d2c76330
FC
541 hg commit -m "good branch" &&
542 hg -q branch bad_branch &&
ff867963 543 echo "bad branch" >content &&
d2c76330
FC
544 hg commit -m "bad branch"
545 ) &&
546
547 git clone "hg::hgrepo" gitrepo &&
548
549 (
550 cd gitrepo &&
ff867963 551 echo two >content &&
d2c76330
FC
552 git commit -q -a -m two &&
553
554 git checkout -q good_bmark &&
ff867963 555 echo three >content &&
d2c76330
FC
556 git commit -q -a -m three &&
557
558 git checkout -q bad_bmark1 &&
559 git reset --hard HEAD^ &&
ff867963 560 echo four >content &&
d2c76330
FC
561 git commit -q -a -m four &&
562
563 git checkout -q bad_bmark2 &&
564 git reset --hard HEAD^ &&
ff867963 565 echo five >content &&
d2c76330
FC
566 git commit -q -a -m five &&
567
568 git checkout -q -b new_bmark master &&
ff867963 569 echo six >content &&
d2c76330
FC
570 git commit -q -a -m six &&
571
572 git checkout -q branches/good_branch &&
ff867963 573 echo seven >content &&
d2c76330 574 git commit -q -a -m seven &&
ff867963 575 echo eight >content &&
d2c76330
FC
576 git commit -q -a -m eight &&
577
578 git checkout -q branches/bad_branch &&
579 git reset --hard HEAD^ &&
ff867963 580 echo nine >content &&
d2c76330
FC
581 git commit -q -a -m nine &&
582
583 git checkout -q -b branches/new_branch master &&
ff867963 584 echo ten >content &&
2b02a405
FC
585 git commit -q -a -m ten
586 )
587}
588
589test_expect_success 'remote big push' '
590 test_when_finished "rm -rf hgrepo gitrepo*" &&
591
592 setup_big_push
d2c76330 593
2b02a405
FC
594 (
595 cd gitrepo &&
42cbbcc7 596
ff867963 597 check_push 1 --all <<-\EOF
42cbbcc7
FC
598 master
599 good_bmark
600 branches/good_branch
601 new_bmark:new
602 branches/new_branch:new
603 bad_bmark1:non-fast-forward
604 bad_bmark2:non-fast-forward
605 branches/bad_branch:non-fast-forward
606 EOF
d2c76330
FC
607 ) &&
608
609 check_branch hgrepo default one &&
610 check_branch hgrepo good_branch "good branch" &&
611 check_branch hgrepo bad_branch "bad branch" &&
612 check_branch hgrepo new_branch '' &&
613 check_bookmark hgrepo good_bmark one &&
614 check_bookmark hgrepo bad_bmark1 one &&
615 check_bookmark hgrepo bad_bmark2 one &&
616 check_bookmark hgrepo new_bmark ''
617'
618
ba091c20
FC
619test_expect_success 'remote big push fetch first' '
620 test_when_finished "rm -rf hgrepo gitrepo*" &&
621
622 (
623 hg init hgrepo &&
624 cd hgrepo &&
ff867963 625 echo zero >content &&
ba091c20
FC
626 hg add content &&
627 hg commit -m zero &&
628 hg bookmark bad_bmark &&
629 hg bookmark good_bmark &&
630 hg bookmark -i good_bmark &&
631 hg -q branch good_branch &&
ff867963 632 echo "good branch" >content &&
ba091c20
FC
633 hg commit -m "good branch" &&
634 hg -q branch bad_branch &&
ff867963 635 echo "bad branch" >content &&
ba091c20
FC
636 hg commit -m "bad branch"
637 ) &&
638
639 git clone "hg::hgrepo" gitrepo &&
640
641 (
642 cd hgrepo &&
643 hg bookmark -f bad_bmark &&
ff867963 644 echo update_bmark >content &&
ba091c20
FC
645 hg commit -m "update bmark"
646 ) &&
647
648 (
649 cd gitrepo &&
ff867963 650 echo two >content &&
ba091c20
FC
651 git commit -q -a -m two &&
652
653 git checkout -q good_bmark &&
ff867963 654 echo three >content &&
ba091c20
FC
655 git commit -q -a -m three &&
656
657 git checkout -q bad_bmark &&
ff867963 658 echo four >content &&
ba091c20
FC
659 git commit -q -a -m four &&
660
661 git checkout -q branches/bad_branch &&
ff867963 662 echo five >content &&
ba091c20
FC
663 git commit -q -a -m five &&
664
ff867963 665 check_push 1 --all <<-\EOF &&
ba091c20
FC
666 master
667 good_bmark
ba091c20
FC
668 bad_bmark:fetch-first
669 branches/bad_branch:festch-first
670 EOF
671
672 git fetch &&
673
ff867963 674 check_push 1 --all <<-\EOF
ba091c20
FC
675 master
676 good_bmark
677 bad_bmark:non-fast-forward
678 branches/bad_branch:non-fast-forward
679 EOF
680 )
681'
682
fdec195f 683test_expect_success 'remote big push force' '
c9eaef12
FC
684 test_when_finished "rm -rf hgrepo gitrepo*" &&
685
686 setup_big_push
687
688 (
689 cd gitrepo &&
690
ff867963 691 check_push 0 --force --all <<-\EOF
c9eaef12
FC
692 master
693 good_bmark
694 branches/good_branch
695 new_bmark:new
696 branches/new_branch:new
697 bad_bmark1:forced-update
698 bad_bmark2:forced-update
699 branches/bad_branch:forced-update
700 EOF
701 ) &&
702
703 check_branch hgrepo default six &&
704 check_branch hgrepo good_branch eight &&
705 check_branch hgrepo bad_branch nine &&
706 check_branch hgrepo new_branch ten &&
707 check_bookmark hgrepo good_bmark three &&
708 check_bookmark hgrepo bad_bmark1 four &&
709 check_bookmark hgrepo bad_bmark2 five &&
710 check_bookmark hgrepo new_bmark six
711'
712
fdec195f 713test_expect_success 'remote big push dry-run' '
e3751a17
FC
714 test_when_finished "rm -rf hgrepo gitrepo*" &&
715
716 setup_big_push
717
718 (
719 cd gitrepo &&
720
ff867963 721 check_push 1 --dry-run --all <<-\EOF &&
e3751a17
FC
722 master
723 good_bmark
724 branches/good_branch
725 new_bmark:new
726 branches/new_branch:new
727 bad_bmark1:non-fast-forward
728 bad_bmark2:non-fast-forward
729 branches/bad_branch:non-fast-forward
730 EOF
731
ff867963 732 check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-\EOF
e3751a17
FC
733 master
734 good_bmark
735 branches/good_branch
736 new_bmark:new
737 branches/new_branch:new
738 EOF
739 ) &&
740
741 check_branch hgrepo default one &&
742 check_branch hgrepo good_branch "good branch" &&
743 check_branch hgrepo bad_branch "bad branch" &&
744 check_branch hgrepo new_branch '' &&
745 check_bookmark hgrepo good_bmark one &&
746 check_bookmark hgrepo bad_bmark1 one &&
747 check_bookmark hgrepo bad_bmark2 one &&
748 check_bookmark hgrepo new_bmark ''
749'
750
b688911a 751test_expect_success 'remote double failed push' '
0bf9ee57
FC
752 test_when_finished "rm -rf hgrepo gitrepo*" &&
753
754 (
755 hg init hgrepo &&
756 cd hgrepo &&
ff867963 757 echo zero >content &&
0bf9ee57
FC
758 hg add content &&
759 hg commit -m zero &&
ff867963 760 echo one >content &&
0bf9ee57
FC
761 hg commit -m one
762 ) &&
763
764 (
765 git clone "hg::hgrepo" gitrepo &&
766 cd gitrepo &&
767 git reset --hard HEAD^ &&
ff867963 768 echo two >content &&
0bf9ee57
FC
769 git commit -a -m two &&
770 test_expect_code 1 git push &&
771 test_expect_code 1 git push
772 )
773'
774
51be46ec
MH
775test_expect_success 'clone remote with master null bookmark, then push to the bookmark' '
776 test_when_finished "rm -rf gitrepo* hgrepo*" &&
777
778 hg init hgrepo &&
779 (
780 cd hgrepo &&
781 echo a >a &&
782 hg add a &&
783 hg commit -m a &&
784 hg bookmark -r null master
785 ) &&
786
787 git clone "hg::hgrepo" gitrepo &&
788 check gitrepo HEAD a &&
789 (
790 cd gitrepo &&
791 git checkout --quiet -b master &&
792 echo b >b &&
793 git add b &&
794 git commit -m b &&
795 git push origin master
796 )
797'
798
799test_expect_success 'clone remote with default null bookmark, then push to the bookmark' '
800 test_when_finished "rm -rf gitrepo* hgrepo*" &&
801
802 hg init hgrepo &&
803 (
804 cd hgrepo &&
805 echo a >a &&
806 hg add a &&
807 hg commit -m a &&
808 hg bookmark -r null -f default
809 ) &&
810
811 git clone "hg::hgrepo" gitrepo &&
812 check gitrepo HEAD a &&
813 (
814 cd gitrepo &&
815 git checkout --quiet -b default &&
816 echo b >b &&
817 git add b &&
818 git commit -m b &&
819 git push origin default
820 )
821'
822
823test_expect_success 'clone remote with generic null bookmark, then push to the bookmark' '
824 test_when_finished "rm -rf gitrepo* hgrepo*" &&
825
826 hg init hgrepo &&
827 (
828 cd hgrepo &&
829 echo a >a &&
830 hg add a &&
831 hg commit -m a &&
832 hg bookmark -r null bmark
833 ) &&
834
835 git clone "hg::hgrepo" gitrepo &&
836 check gitrepo HEAD a &&
837 (
838 cd gitrepo &&
839 git checkout --quiet -b bmark &&
840 git remote -v &&
841 echo b >b &&
842 git add b &&
843 git commit -m b &&
844 git push origin bmark
845 )
846'
847
7ee719e1 848test_done