summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2014-05-03 21:16:52 -0500
committerJunio C Hamano <gitster@pobox.com>2014-05-07 11:16:13 -0700
commit911c7783a461568250ac8f6619a45e3030f9b44d (patch)
treef0223d6baddc0e101a2ccf392a2f60361a780595
parent0bbe16f12905305180879346fee49c2f7efee9df (diff)
downloadgit-911c7783a461568250ac8f6619a45e3030f9b44d.tar.gz
t: remote-hg: add file operation tests
Inspired by gitifyhg. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xcontrib/remote-helpers/test-hg.sh76
1 files changed, 76 insertions, 0 deletions
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index a403c9ac7d..2628f8eb77 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -53,6 +53,17 @@ check_bookmark () {
fi
}
+check_files () {
+ git --git-dir=$1/.git ls-files > actual &&
+ if test $# -gt 1
+ then
+ printf "%s\n" "$2" > expected
+ else
+ > expected
+ fi &&
+ test_cmp expected actual
+}
+
check_push () {
expected_ret=$1 ret=0 ref_ret=0
@@ -995,4 +1006,69 @@ test_expect_success 'push tag different branch' '
test_cmp expected actual
'
+test_expect_success 'cloning a removed file works' '
+ test_when_finished "rm -rf hgrepo gitrepo" &&
+
+ (
+ hg init hgrepo &&
+ cd hgrepo &&
+
+ echo test > test_file &&
+ hg add test_file &&
+ hg commit -m add &&
+
+ hg rm test_file &&
+ hg commit -m remove
+ ) &&
+
+ git clone "hg::hgrepo" gitrepo &&
+ check_files gitrepo
+'
+
+test_expect_success 'cloning a file replaced with a directory' '
+ test_when_finished "rm -rf hgrepo gitrepo" &&
+
+ (
+ hg init hgrepo &&
+ cd hgrepo &&
+
+ echo test > dir_or_file &&
+ hg add dir_or_file &&
+ hg commit -m add &&
+
+ hg rm dir_or_file &&
+ mkdir dir_or_file &&
+ echo test > dir_or_file/test_file &&
+ hg add dir_or_file/test_file &&
+ hg commit -m replase
+ ) &&
+
+ git clone "hg::hgrepo" gitrepo &&
+ check_files gitrepo "dir_or_file/test_file"
+'
+
+test_expect_success 'clone replace directory with a file' '
+ test_when_finished "rm -rf hgrepo gitrepo" &&
+
+ (
+ hg init hgrepo &&
+ cd hgrepo &&
+
+ mkdir dir_or_file &&
+ echo test > dir_or_file/test_file &&
+ hg add dir_or_file/test_file &&
+ hg commit -m add &&
+
+ hg rm dir_or_file/test_file &&
+ echo test > dir_or_file &&
+ hg add dir_or_file &&
+ hg commit -m add &&
+
+ hg rm dir_or_file
+ ) &&
+
+ git clone "hg::hgrepo" gitrepo &&
+ check_files gitrepo "dir_or_file"
+'
+
test_done