]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote-hg: add test for big push
authorFelipe Contreras <felipe.contreras@gmail.com>
Sat, 25 May 2013 02:29:44 +0000 (21:29 -0500)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 May 2013 15:02:03 +0000 (08:02 -0700)
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>
contrib/remote-helpers/test-hg.sh

index 7a6e5dab51034e5096ac496e26cb76d82b715f94..66e37af09a7d0cbd86fa992bc822b28944ffd85f 100755 (executable)
@@ -27,15 +27,25 @@ check () {
 }
 
 check_branch () {
-       echo $3 > expected &&
-       hg -R $1 log -r $2 --template '{desc}\n' > actual &&
-       test_cmp expected actual
+       if [ -n "$3" ]; then
+               echo $3 > expected &&
+               hg -R $1 log -r $2 --template '{desc}\n' > actual &&
+               test_cmp expected actual
+       else
+               hg -R $1 branches > out &&
+               ! grep $2 out
+       fi
 }
 
 check_bookmark () {
-       echo $3 > expected &&
-       hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
-       test_cmp expected actual
+       if [ -n "$3" ]; then
+               echo $3 > expected &&
+               hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
+               test_cmp expected actual
+       else
+               hg -R $1 bookmarks > out &&
+               ! grep $2 out
+       fi
 }
 
 setup () {
@@ -385,4 +395,95 @@ test_expect_failure 'remote new bookmark multiple branch head' '
        check_bookmark hgrepo feature-c feature-c
 '
 
+# cleanup previous stuff
+rm -rf hgrepo
+
+test_expect_failure 'remote big push' '
+       test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+       (
+       hg init hgrepo &&
+       cd hgrepo &&
+       echo zero > content &&
+       hg add content &&
+       hg commit -m zero &&
+       hg bookmark bad_bmark1 &&
+       echo one > content &&
+       hg commit -m one &&
+       hg bookmark bad_bmark2 &&
+       hg bookmark good_bmark &&
+       hg bookmark -i good_bmark &&
+       hg -q branch good_branch &&
+       echo "good branch" > content &&
+       hg commit -m "good branch" &&
+       hg -q branch bad_branch &&
+       echo "bad branch" > content &&
+       hg commit -m "bad branch"
+       ) &&
+
+       git clone "hg::hgrepo" gitrepo &&
+
+       (
+       cd gitrepo &&
+       echo two > content &&
+       git commit -q -a -m two &&
+
+       git checkout -q good_bmark &&
+       echo three > content &&
+       git commit -q -a -m three &&
+
+       git checkout -q bad_bmark1 &&
+       git reset --hard HEAD^ &&
+       echo four > content &&
+       git commit -q -a -m four &&
+
+       git checkout -q bad_bmark2 &&
+       git reset --hard HEAD^ &&
+       echo five > content &&
+       git commit -q -a -m five &&
+
+       git checkout -q -b new_bmark master &&
+       echo six > content &&
+       git commit -q -a -m six &&
+
+       git checkout -q branches/good_branch &&
+       echo seven > content &&
+       git commit -q -a -m seven &&
+       echo eight > content &&
+       git commit -q -a -m eight &&
+
+       git checkout -q branches/bad_branch &&
+       git reset --hard HEAD^ &&
+       echo nine > content &&
+       git commit -q -a -m nine &&
+
+       git checkout -q -b branches/new_branch master &&
+       echo ten > content &&
+       git commit -q -a -m ten &&
+
+       test_expect_code 1 git push origin master \
+               good_bmark bad_bmark1 bad_bmark2 new_bmark \
+               branches/good_branch branches/bad_branch \
+               branches/new_branch 2> error &&
+
+       grep "^   [a-f0-9]*\.\.[a-f0-9]* *master -> master$" error &&
+       grep "^   [a-f0-9]*\.\.[a-f0-9]* *good_bmark -> good_bmark$" error &&
+       grep "^ \* \[new branch\] *new_bmark -> new_bmark$" error &&
+       grep "^ ! \[rejected\] *bad_bmark2 -> bad_bmark2 (non-fast-forward)$" error &&
+       grep "^ ! \[rejected\] *bad_bmark1 -> bad_bmark1 (non-fast-forward)$" error &&
+       grep "^   [a-f0-9]*\.\.[a-f0-9]* *branches/good_branch -> branches/good_branch$" error &&
+       grep "^ ! \[rejected\] *branches/bad_branch -> branches/bad_branch (non-fast-forward)$" error &&
+       grep "^ \* \[new branch\] *branches/new_branch -> branches/new_branch$" error
+       ) &&
+
+       check_branch hgrepo default one &&
+       check_branch hgrepo good_branch "good branch" &&
+       check_branch hgrepo bad_branch "bad branch" &&
+       check_branch hgrepo new_branch '' &&
+       check_bookmark hgrepo good_bmark one &&
+       check_bookmark hgrepo bad_bmark1 one &&
+       check_bookmark hgrepo bad_bmark2 one &&
+       check_bookmark hgrepo new_bmark ''
+'
+
 test_done