remote-hg: use notes to keep track of Hg revisions
[gitweb.git] / contrib / remote-helpers / test-hg.sh
index 41ea2e8083ac36ed65dc1c56bf1e9882e262cc48..5a6f7451babe71871a8363bb3b21dc1d5b690825 100755 (executable)
@@ -68,14 +68,17 @@ check_push () {
                'fetch-first')
                        grep "^ ! \[rejected\] *${branch} -> ${branch} (fetch first)$" error || ref_ret=1
                        ;;
+               'forced-update')
+                       grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *${branch} -> ${branch} (forced update)$" error || ref_ret=1
+                       ;;
                '')
                        grep "^   [a-f0-9]*\.\.[a-f0-9]* *${branch} -> ${branch}$" error || ref_ret=1
                        ;;
                esac
-               let 'ref_ret' && echo "match for '$branch' failed" && break
+               test $ref_ret -ne 0 && echo "match for '$branch' failed" && break
        done
 
-       if let 'expected_ret != ret || ref_ret'
+       if test $expected_ret -ne $ret -o $ref_ret -ne 0
        then
                return 1
        fi
@@ -574,11 +577,9 @@ test_expect_success 'remote big push fetch first' '
        echo five > content &&
        git commit -q -a -m five &&
 
-       check_push 1 --all <<-EOF
+       check_push 1 --all <<-EOF &&
        master
        good_bmark
-       new_bmark:new
-       new_branch:new
        bad_bmark:fetch-first
        branches/bad_branch:festch-first
        EOF
@@ -594,6 +595,74 @@ test_expect_success 'remote big push fetch first' '
        )
 '
 
+test_expect_failure 'remote big push force' '
+       test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+       setup_big_push
+
+       (
+       cd gitrepo &&
+
+       check_push 0 --force --all <<-EOF
+       master
+       good_bmark
+       branches/good_branch
+       new_bmark:new
+       branches/new_branch:new
+       bad_bmark1:forced-update
+       bad_bmark2:forced-update
+       branches/bad_branch:forced-update
+       EOF
+       ) &&
+
+       check_branch hgrepo default six &&
+       check_branch hgrepo good_branch eight &&
+       check_branch hgrepo bad_branch nine &&
+       check_branch hgrepo new_branch ten &&
+       check_bookmark hgrepo good_bmark three &&
+       check_bookmark hgrepo bad_bmark1 four &&
+       check_bookmark hgrepo bad_bmark2 five &&
+       check_bookmark hgrepo new_bmark six
+'
+
+test_expect_failure 'remote big push dry-run' '
+       test_when_finished "rm -rf hgrepo gitrepo*" &&
+
+       setup_big_push
+
+       (
+       cd gitrepo &&
+
+       check_push 1 --dry-run --all <<-EOF &&
+       master
+       good_bmark
+       branches/good_branch
+       new_bmark:new
+       branches/new_branch:new
+       bad_bmark1:non-fast-forward
+       bad_bmark2:non-fast-forward
+       branches/bad_branch:non-fast-forward
+       EOF
+
+       check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
+       master
+       good_bmark
+       branches/good_branch
+       new_bmark:new
+       branches/new_branch:new
+       EOF
+       ) &&
+
+       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_expect_success 'remote double failed push' '
        test_when_finished "rm -rf hgrepo gitrepo*" &&