remote-hg: don't update bookmarks unnecessarily
[gitweb.git] / contrib / remote-helpers / test-hg-hg-git.sh
index 3e76d9fb60bff8b25f5b2751c6e11cfabb6c9dc6..253e65aaa8881581b971eb51d518a4ad393f4b3d 100755 (executable)
@@ -27,7 +27,6 @@ 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
 }
 
@@ -35,6 +34,7 @@ git_clone_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/*'
        ) &&
@@ -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
        )
 }
@@ -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,6 +98,7 @@ 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
@@ -109,6 +111,73 @@ setup () {
 
 setup
 
+test_expect_success 'executable bit' '
+       mkdir -p tmp && cd tmp &&
+       test_when_finished "cd .. && rm -rf tmp" &&
+
+       (
+       git init -q gitrepo &&
+       cd gitrepo &&
+       echo alpha > alpha &&
+       chmod 0644 alpha &&
+       git add alpha &&
+       git commit -m "add alpha" &&
+       chmod 0755 alpha &&
+       git add alpha &&
+       git commit -m "set executable bit" &&
+       chmod 0644 alpha &&
+       git add alpha &&
+       git commit -m "clear executable bit"
+       ) &&
+
+       for x in hg git; do
+               (
+               hg_clone_$x gitrepo hgrepo-$x &&
+               cd hgrepo-$x &&
+               hg_log . &&
+               hg manifest -r 1 -v &&
+               hg manifest -v
+               ) > output-$x &&
+
+               git_clone_$x hgrepo-$x gitrepo2-$x &&
+               git_log gitrepo2-$x > log-$x
+       done &&
+
+       test_cmp output-hg output-git &&
+       test_cmp log-hg log-git
+'
+
+test_expect_success 'symlink' '
+       mkdir -p tmp && cd tmp &&
+       test_when_finished "cd .. && rm -rf tmp" &&
+
+       (
+       git init -q gitrepo &&
+       cd gitrepo &&
+       echo alpha > alpha &&
+       git add alpha &&
+       git commit -m "add alpha" &&
+       ln -s alpha beta &&
+       git add beta &&
+       git commit -m "add beta"
+       ) &&
+
+       for x in hg git; do
+               (
+               hg_clone_$x gitrepo hgrepo-$x &&
+               cd hgrepo-$x &&
+               hg_log . &&
+               hg manifest -v
+               ) > output-$x &&
+
+               git_clone_$x hgrepo-$x gitrepo2-$x &&
+               git_log gitrepo2-$x > log-$x
+       done &&
+
+       test_cmp output-hg output-git &&
+       test_cmp log-hg log-git
+'
+
 test_expect_success 'merge conflict 1' '
        mkdir -p tmp && cd tmp &&
        test_when_finished "cd .. && rm -rf tmp" &&