remote-hg: add test for big push
With lots branches and bookmarks, non-ff, updated and new. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
May 24, 2013 at 21:29 UTC
d2c76330286c8bd604f9fbbb7818cecce893b769
1 file changed
+107
-6
contrib/remote-helpers/test-hg.sh
+107
-6
@@ -27,15 +27,25 @@ check () {
27
}
28
29
check_branch () {
30
- echo $3 > expected &&
31
- hg -R $1 log -r $2 --template '{desc}\n' > actual &&
32
- test_cmp expected actual
30
+ if [ -n "$3" ]; then
31
+ echo $3 > expected &&
32
+ hg -R $1 log -r $2 --template '{desc}\n' > actual &&
33
+ test_cmp expected actual
34
+ else
35
+ hg -R $1 branches > out &&
36
+ ! grep $2 out
37
+ fi
38
}
39
40
check_bookmark () {
36
- echo $3 > expected &&
37
- hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
38
- test_cmp expected actual
41
+ if [ -n "$3" ]; then
42
+ echo $3 > expected &&
43
+ hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
44
+ test_cmp expected actual
45
+ else
46
+ hg -R $1 bookmarks > out &&
47
+ ! grep $2 out
48
+ fi
49
}
50
51
setup () {
@@ -385,4 +395,95 @@ test_expect_failure 'remote new bookmark multiple branch head' '
395
check_bookmark hgrepo feature-c feature-c
396
'
397
398
+# cleanup previous stuff
399
+rm -rf hgrepo
400
+
401
+test_expect_failure 'remote big push' '
402
+ test_when_finished "rm -rf hgrepo gitrepo*" &&
403
+
404
+ (
405
+ hg init hgrepo &&
406
+ cd hgrepo &&
407
+ echo zero > content &&
408
+ hg add content &&
409
+ hg commit -m zero &&
410
+ hg bookmark bad_bmark1 &&
411
+ echo one > content &&
412
+ hg commit -m one &&
413
+ hg bookmark bad_bmark2 &&
414
+ hg bookmark good_bmark &&
415
+ hg bookmark -i good_bmark &&
416
+ hg -q branch good_branch &&
417
+ echo "good branch" > content &&
418
+ hg commit -m "good branch" &&
419
+ hg -q branch bad_branch &&
420
+ echo "bad branch" > content &&
421
+ hg commit -m "bad branch"
422
+ ) &&
423
+
424
+ git clone "hg::hgrepo" gitrepo &&
425
+
426
+ (
427
+ cd gitrepo &&
428
+ echo two > content &&
429
+ git commit -q -a -m two &&
430
+
431
+ git checkout -q good_bmark &&
432
+ echo three > content &&
433
+ git commit -q -a -m three &&
434
+
435
+ git checkout -q bad_bmark1 &&
436
+ git reset --hard HEAD^ &&
437
+ echo four > content &&
438
+ git commit -q -a -m four &&
439
+
440
+ git checkout -q bad_bmark2 &&
441
+ git reset --hard HEAD^ &&
442
+ echo five > content &&
443
+ git commit -q -a -m five &&
444
+
445
+ git checkout -q -b new_bmark master &&
446
+ echo six > content &&
447
+ git commit -q -a -m six &&
448
+
449
+ git checkout -q branches/good_branch &&
450
+ echo seven > content &&
451
+ git commit -q -a -m seven &&
452
+ echo eight > content &&
453
+ git commit -q -a -m eight &&
454
+
455
+ git checkout -q branches/bad_branch &&
456
+ git reset --hard HEAD^ &&
457
+ echo nine > content &&
458
+ git commit -q -a -m nine &&
459
+
460
+ git checkout -q -b branches/new_branch master &&
461
+ echo ten > content &&
462
+ git commit -q -a -m ten &&
463
+
464
+ test_expect_code 1 git push origin master \
465
+ good_bmark bad_bmark1 bad_bmark2 new_bmark \
466
+ branches/good_branch branches/bad_branch \
467
+ branches/new_branch 2> error &&
468
+
469
+ grep "^ [a-f0-9]*\.\.[a-f0-9]* *master -> master$" error &&
470
+ grep "^ [a-f0-9]*\.\.[a-f0-9]* *good_bmark -> good_bmark$" error &&
471
+ grep "^ \* \[new branch\] *new_bmark -> new_bmark$" error &&
472
+ grep "^ ! \[rejected\] *bad_bmark2 -> bad_bmark2 (non-fast-forward)$" error &&
473
+ grep "^ ! \[rejected\] *bad_bmark1 -> bad_bmark1 (non-fast-forward)$" error &&
474
+ grep "^ [a-f0-9]*\.\.[a-f0-9]* *branches/good_branch -> branches/good_branch$" error &&
475
+ grep "^ ! \[rejected\] *branches/bad_branch -> branches/bad_branch (non-fast-forward)$" error &&
476
+ grep "^ \* \[new branch\] *branches/new_branch -> branches/new_branch$" error
477
+ ) &&
478
+
479
+ check_branch hgrepo default one &&
480
+ check_branch hgrepo good_branch "good branch" &&
481
+ check_branch hgrepo bad_branch "bad branch" &&
482
+ check_branch hgrepo new_branch '' &&
483
+ check_bookmark hgrepo good_bmark one &&
484
+ check_bookmark hgrepo bad_bmark1 one &&
485
+ check_bookmark hgrepo bad_bmark2 one &&
486
+ check_bookmark hgrepo new_bmark ''
487
+'
488
+
489
test_done