remote-helpers: test: simplify remote URLs
[gitweb.git] / contrib / remote-helpers / test-hg-hg-git.sh
index 3f253b7de75a6fa44c4cff3b2e1f53f9feffcf5d..c2e7316385e05c74a804699a1a1a3f996943e252 100755 (executable)
@@ -15,28 +15,28 @@ if ! test_have_prereq PYTHON; then
        test_done
 fi
 
-if ! "$PYTHON_PATH" -c 'import mercurial'; then
+if ! python -c 'import mercurial'; then
        skip_all='skipping remote-hg tests; mercurial not available'
        test_done
 fi
 
-if ! "$PYTHON_PATH" -c 'import hggit'; then
+if ! python -c 'import hggit'; then
        skip_all='skipping remote-hg tests; hg-git not available'
        test_done
 fi
 
 # clone to a git repo with git
 git_clone_git () {
-       hg -R $1 bookmark -f -r tip master &&
-       git clone -q "hg::$PWD/$1" $2
+       git clone -q "hg::$1" $2
 }
 
 # clone to an hg repo with git
 hg_clone_git () {
        (
        hg init $2 &&
+       hg -R $2 bookmark -i master &&
        cd $1 &&
-       git push -q "hg::$PWD/../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
+       git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
        ) &&
 
        (cd $2 && hg -q update)
@@ -47,7 +47,7 @@ git_clone_hg () {
        (
        git init -q $2 &&
        cd $1 &&
-       hg bookmark -f -r tip master &&
+       hg bookmark -i -f -r tip master &&
        hg -q push -r master ../$2 || true
        )
 }
@@ -63,7 +63,7 @@ hg_push_git () {
        cd $2
        old=$(git symbolic-ref --short HEAD)
        git checkout -q -b tmp &&
-       git fetch -q "hg::$PWD/../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
+       git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
        git checkout -q $old &&
        git branch -q -D tmp 2> /dev/null || true
        )
@@ -78,7 +78,8 @@ hg_push_hg () {
 }
 
 hg_log () {
-       hg -R $1 log --graph --debug | grep -v 'tag: *default/'
+       hg -R $1 log --graph --debug >log &&
+       grep -v 'tag: *default/' log
 }
 
 git_log () {
@@ -97,21 +98,24 @@ setup () {
        echo "[extensions]"
        echo "hgext.bookmarks ="
        echo "hggit ="
+       echo "graphlog ="
        ) >> "$HOME"/.hgrc &&
        git config --global receive.denycurrentbranch warn
        git config --global remote-hg.hg-git-compat true
+       git config --global remote-hg.track-branches false
 
-       export HGEDITOR=/usr/bin/true
+       HGEDITOR=true
+       HGMERGE=true
 
-       export GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
-       export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+       GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
+       GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
+       export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
 }
 
 setup
 
 test_expect_success 'executable bit' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        (
        git init -q gitrepo &&
@@ -146,8 +150,7 @@ test_expect_success 'executable bit' '
 '
 
 test_expect_success 'symlink' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        (
        git init -q gitrepo &&
@@ -177,8 +180,7 @@ test_expect_success 'symlink' '
 '
 
 test_expect_success 'merge conflict 1' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        (
        hg init hgrepo1 &&
@@ -194,7 +196,7 @@ test_expect_success 'merge conflict 1' '
        echo C > afile &&
        hg ci -m "A->C" &&
 
-       hg merge -r1 || true &&
+       hg merge -r1 &&
        echo C > afile &&
        hg resolve -m afile &&
        hg ci -m "merge to C"
@@ -212,8 +214,7 @@ test_expect_success 'merge conflict 1' '
 '
 
 test_expect_success 'merge conflict 2' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        (
        hg init hgrepo1 &&
@@ -247,8 +248,7 @@ test_expect_success 'merge conflict 2' '
 '
 
 test_expect_success 'converged merge' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        (
        hg init hgrepo1 &&
@@ -283,8 +283,7 @@ test_expect_success 'converged merge' '
 '
 
 test_expect_success 'encoding' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        (
        git init -q gitrepo &&
@@ -294,7 +293,8 @@ test_expect_success 'encoding' '
        git add alpha &&
        git commit -m "add älphà" &&
 
-       export GIT_AUTHOR_NAME="tést èncödîng" &&
+       GIT_AUTHOR_NAME="tést èncödîng" &&
+       export GIT_AUTHOR_NAME &&
        echo beta > beta &&
        git add beta &&
        git commit -m "add beta" &&
@@ -322,8 +322,7 @@ test_expect_success 'encoding' '
 '
 
 test_expect_success 'file removal' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        (
        git init -q gitrepo &&
@@ -362,8 +361,7 @@ test_expect_success 'file removal' '
 '
 
 test_expect_success 'git tags' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        (
        git init -q gitrepo &&
@@ -389,8 +387,7 @@ test_expect_success 'git tags' '
 '
 
 test_expect_success 'hg author' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        for x in hg git; do
                (
@@ -451,15 +448,12 @@ test_expect_success 'hg author' '
                git_log gitrepo-$x > git-log-$x
        done &&
 
-       test_cmp git-log-hg git-log-git &&
-
        test_cmp hg-log-hg hg-log-git &&
        test_cmp git-log-hg git-log-git
 '
 
 test_expect_success 'hg branch' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        for x in hg git; do
                (
@@ -495,8 +489,7 @@ test_expect_success 'hg branch' '
 '
 
 test_expect_success 'hg tags' '
-       mkdir -p tmp && cd tmp &&
-       test_when_finished "cd .. && rm -rf tmp" &&
+       test_when_finished "rm -rf gitrepo* hgrepo*" &&
 
        for x in hg git; do
                (