3 # Copyright (c) 2012 Felipe Contreras
5 # Base commands from hg-git tests:
6 # https://bitbucket.org/durin42/hg-git/src
9 test_description='Test bidirectionality of remote-hg'
11 test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/.."
12 . "$TEST_DIRECTORY"/test-lib.sh
14 if ! test_have_prereq PYTHON; then
15 skip_all='skipping remote-hg tests; python not available'
19 if ! "$PYTHON_PATH" -c 'import mercurial'; then
20 skip_all='skipping remote-hg tests; mercurial not available'
26 git clone -q "hg::$1" $2
34 git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
37 (cd $2 && hg -q update)
44 git checkout -q -b tmp &&
45 git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
46 git checkout -q @{-1} &&
47 git branch -q -D tmp 2> /dev/null || true
52 hg -R $1 log --graph --debug
58 echo "username = A U Thor <author@example.com>"
60 echo "backout = -d \"0 0\""
61 echo "commit = -d \"0 0\""
62 echo "debugrawcommit = -d \"0 0\""
63 echo "tag = -d \"0 0\""
67 git config --global remote-hg.hg-git-compat true
68 git config --global remote-hg.track-branches true
70 HGEDITOR=/usr/bin/true
71 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
72 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
73 export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
78 test_expect_success 'encoding' '
79 test_when_finished "rm -rf gitrepo* hgrepo*" &&
82 git init -q gitrepo &&
87 git commit -m "add älphà" &&
89 GIT_AUTHOR_NAME="tést èncödîng" &&
90 export GIT_AUTHOR_NAME &&
93 git commit -m "add beta" &&
97 git commit -m "add gämmâ" &&
99 : TODO git config i18n.commitencoding latin-1 &&
100 echo delta > delta &&
102 git commit -m "add déltà"
105 hg_clone gitrepo hgrepo &&
106 git_clone hgrepo gitrepo2 &&
107 hg_clone gitrepo2 hgrepo2 &&
109 HGENCODING=utf-8 hg_log hgrepo > expected &&
110 HGENCODING=utf-8 hg_log hgrepo2 > actual &&
112 test_cmp expected actual
115 test_expect_success 'file removal' '
116 test_when_finished "rm -rf gitrepo* hgrepo*" &&
119 git init -q gitrepo &&
121 echo alpha > alpha &&
123 git commit -m "add alpha" &&
126 git commit -m "add beta"
128 echo blah > foo/bar &&
130 git commit -m "add foo" &&
132 git commit -m "remove alpha" &&
134 git commit -m "remove foo/bar"
137 hg_clone gitrepo hgrepo &&
138 git_clone hgrepo gitrepo2 &&
139 hg_clone gitrepo2 hgrepo2 &&
141 hg_log hgrepo > expected &&
142 hg_log hgrepo2 > actual &&
144 test_cmp expected actual
147 test_expect_success 'git tags' '
148 test_when_finished "rm -rf gitrepo* hgrepo*" &&
151 git init -q gitrepo &&
153 git config receive.denyCurrentBranch ignore &&
154 echo alpha > alpha &&
156 git commit -m "add alpha" &&
161 git commit -m "add beta" &&
162 git tag -a -m "added tag beta" beta
165 hg_clone gitrepo hgrepo &&
166 git_clone hgrepo gitrepo2 &&
167 hg_clone gitrepo2 hgrepo2 &&
169 hg_log hgrepo > expected &&
170 hg_log hgrepo2 > actual &&
172 test_cmp expected actual
175 test_expect_success 'hg branch' '
176 test_when_finished "rm -rf gitrepo* hgrepo*" &&
179 git init -q gitrepo &&
182 echo alpha > alpha &&
184 git commit -q -m "add alpha" &&
185 git checkout -q -b not-master
189 hg_clone gitrepo hgrepo &&
194 hg -q commit -m "rename alpha to beta" &&
195 hg branch gamma | grep -v "permanent and global" &&
196 hg -q commit -m "started branch gamma"
199 hg_push hgrepo gitrepo &&
200 hg_clone gitrepo hgrepo2 &&
202 : Back to the common revision &&
203 (cd hgrepo && hg checkout default) &&
205 hg_log hgrepo > expected &&
206 hg_log hgrepo2 > actual &&
208 test_cmp expected actual
211 test_expect_success 'hg tags' '
212 test_when_finished "rm -rf gitrepo* hgrepo*" &&
215 git init -q gitrepo &&
218 echo alpha > alpha &&
220 git commit -m "add alpha" &&
221 git checkout -q -b not-master
225 hg_clone gitrepo hgrepo &&
232 hg_push hgrepo gitrepo &&
233 hg_clone gitrepo hgrepo2 &&
235 hg_log hgrepo > expected &&
236 hg_log hgrepo2 > actual &&
238 test_cmp expected actual