1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-02 07:17:58 +01:00
git/contrib/remote-helpers/test-hg.sh
Junio C Hamano 37d32de72a Merge branch 'fc/remote-hg'
Updates remote-hg helper (in contrib/).

* fc/remote-hg: (21 commits)
  remote-hg: activate graphlog extension for hg_log()
  remote-hg: fix bad file paths
  remote-hg: document location of stored hg repository
  remote-hg: fix bad state issue
  remote-hg: add 'insecure' option
  remote-hg: add simple mail test
  remote-hg: add basic author tests
  remote-hg: show more proper errors
  remote-hg: force remote push
  remote-hg: push to the appropriate branch
  remote-hg: update tags globally
  remote-hg: update remote bookmarks
  remote-hg: refactor export
  remote-hg: split bookmark handling
  remote-hg: redirect buggy mercurial output
  remote-hg: trivial test cleanups
  remote-hg: make sure fake bookmarks are updated
  remote-hg: fix for files with spaces
  remote-hg: properly report errors on bookmark pushes
  remote-hg: add missing config variable in doc
  ...
2013-04-21 18:39:58 -07:00

157 lines
3.3 KiB
Bash
Executable file

#!/bin/sh
#
# Copyright (c) 2012 Felipe Contreras
#
# Base commands from hg-git tests:
# https://bitbucket.org/durin42/hg-git/src
#
test_description='Test remote-hg'
. ./test-lib.sh
if ! test_have_prereq PYTHON; then
skip_all='skipping remote-hg tests; python not available'
test_done
fi
if ! "$PYTHON_PATH" -c 'import mercurial'; then
skip_all='skipping remote-hg tests; mercurial not available'
test_done
fi
check () {
(cd $1 &&
git log --format='%s' -1 &&
git symbolic-ref HEAD) > actual &&
(echo $2 &&
echo "refs/heads/$3") > expected &&
test_cmp expected actual
}
setup () {
(
echo "[ui]"
echo "username = H G Wells <wells@example.com>"
) >> "$HOME"/.hgrc
}
setup
test_expect_success 'cloning' '
test_when_finished "rm -rf gitrepo*" &&
(
hg init hgrepo &&
cd hgrepo &&
echo zero > content &&
hg add content &&
hg commit -m zero
) &&
git clone "hg::$PWD/hgrepo" gitrepo &&
check gitrepo zero master
'
test_expect_success 'cloning with branches' '
test_when_finished "rm -rf gitrepo*" &&
(
cd hgrepo &&
hg branch next &&
echo next > content &&
hg commit -m next
) &&
git clone "hg::$PWD/hgrepo" gitrepo &&
check gitrepo next next &&
(cd hgrepo && hg checkout default) &&
git clone "hg::$PWD/hgrepo" gitrepo2 &&
check gitrepo2 zero master
'
test_expect_success 'cloning with bookmarks' '
test_when_finished "rm -rf gitrepo*" &&
(
cd hgrepo &&
hg bookmark feature-a &&
echo feature-a > content &&
hg commit -m feature-a
) &&
git clone "hg::$PWD/hgrepo" gitrepo &&
check gitrepo feature-a feature-a
'
test_expect_success 'cloning with detached head' '
test_when_finished "rm -rf gitrepo*" &&
(
cd hgrepo &&
hg update -r 0
) &&
git clone "hg::$PWD/hgrepo" gitrepo &&
check gitrepo zero master
'
test_expect_success 'update bookmark' '
test_when_finished "rm -rf gitrepo*" &&
(
cd hgrepo &&
hg bookmark devel
) &&
(
git clone "hg::$PWD/hgrepo" gitrepo &&
cd gitrepo &&
git checkout devel &&
echo devel > content &&
git commit -a -m devel &&
git push
) &&
hg -R hgrepo bookmarks | egrep "devel[ ]+3:"
'
author_test () {
echo $1 >> content &&
hg commit -u "$2" -m "add $1" &&
echo "$3" >> ../expected
}
test_expect_success 'authors' '
mkdir -p tmp && cd tmp &&
test_when_finished "cd .. && rm -rf tmp" &&
(
hg init hgrepo &&
cd hgrepo &&
touch content &&
hg add content &&
author_test alpha "" "H G Wells <wells@example.com>" &&
author_test beta "test" "test <unknown>" &&
author_test beta "test <test@example.com> (comment)" "test <unknown>" &&
author_test gamma "<test@example.com>" "Unknown <test@example.com>" &&
author_test delta "name<test@example.com>" "name <test@example.com>" &&
author_test epsilon "name <test@example.com" "name <unknown>" &&
author_test zeta " test " "test <unknown>" &&
author_test eta "test < test@example.com >" "test <test@example.com>" &&
author_test theta "test >test@example.com>" "test <unknown>" &&
author_test iota "test < test <at> example <dot> com>" "test <unknown>" &&
author_test kappa "test@example.com" "test@example.com <unknown>"
) &&
git clone "hg::$PWD/hgrepo" gitrepo &&
git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
test_cmp expected actual
'
test_done