git-remote-hg: add tests
[git/mjg.git] / t / t5801-remote-hg.sh
blob18915ddb8cc90cdec62ee6e540f72188e727fb76
1 #!/bin/sh
3 # Copyright (c) 2010 Sverre Rabbelier
6 test_description='Test remote-helper import and export commands'
8 . ./test-lib.sh
10 if test_have_prereq PYTHON && "$PYTHON_PATH" -c '
11 import sys
12 if sys.hexversion < 0x02040000:
13 sys.exit(1)
15 then
17 else
18 skip_all='skipping git remote-hg tests: requires Python 2.4 or newer'
19 test_done
22 # Call cmp with the arguments -x ".hg" -x ".git" <left> <right>
24 vcs_cmp () {
25 $DIFF -u -x ".hg" -x ".git" $1 $2
28 ROOT=$PWD
30 test_expect_success 'setup repository' '
31 printf "[ui]\nusername = A U Thor <author@example.com>" > \
32 ${HOME}/.hgrc &&
33 mkdir server &&
34 hg init server/.hg &&
35 hg clone "$ROOT/server" public &&
36 (cd public &&
37 echo content >file &&
38 hg add file &&
39 hg commit -m one &&
40 hg push)
43 test_expect_success 'cloning from local repo' '
44 git clone "hg::file://${ROOT}/server" localclone &&
45 vcs_cmp public localclone
48 test_expect_success 'cloning from remote repo' '
49 git clone "hg::remote://${ROOT}/server" clone &&
50 vcs_cmp public clone
53 test_expect_success 'create new commit on remote' '
54 (cd public &&
55 echo content >>file &&
56 hg commit -A -m two &&
57 hg push)
60 test_expect_success 'pulling from local repo' '
61 (cd localclone && git pull) &&
62 vcs_cmp public localclone
65 test_expect_success 'pulling from remote remote' '
66 (cd clone && git pull) &&
67 vcs_cmp public clone
70 test_expect_success 'pushing to local empty repo' '
71 hg init localempty &&
72 (cd localclone &&
73 git push --all "hg::file://${ROOT}/localempty") &&
74 (cd localempty &&
75 hg up tip) &&
76 vcs_cmp localclone localempty
79 test_expect_success 'pushing to remote empty repo' '
80 hg init empty &&
81 (cd localclone &&
82 git push --all "hg::remote://${ROOT}/empty") &&
83 (cd empty &&
84 hg up tip) &&
85 vcs_cmp localclone empty
88 test_expect_success 'pushing to local repo' '
89 (cd localclone &&
90 echo content >>file &&
91 git commit -a -m three &&
92 git push) &&
93 (cd server &&
94 hg up tip) &&
95 vcs_cmp localclone server
98 test_expect_success 'synch with changes from localclone' '
99 (cd clone &&
100 git pull)
103 test_expect_success 'pushing remote local repo' '
104 (cd clone &&
105 echo content >>file &&
106 git commit -a -m four &&
107 git push) &&
108 (cd server &&
109 hg up tip) &&
110 vcs_cmp clone server
113 test_expect_success 'creating new branch' '
114 (cd public &&
115 hg branch different-branch &&
116 echo different >> file &&
117 hg commit -m five &&
118 hg push -f)
121 test_expect_success 'pull in new branch to local repository' '
122 (cd localclone &&
123 git fetch origin default &&
124 test_must_fail git rev-parse -q --verify refs/remotes/origin/different-branch &&
125 git fetch &&
126 git rev-parse --no-revs --verify refs/remotes/origin/different-branch)
129 test_expect_success 'pull in new branch to remote repository' '
130 (cd clone &&
131 git fetch origin default &&
132 test_must_fail git rev-parse -q --verify refs/remotes/origin/different-branch &&
133 git fetch &&
134 git rev-parse --no-revs --verify refs/remotes/origin/different-branch)
137 test_done