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'
13 if ! test_have_prereq PYTHON
; then
14 skip_all
='skipping remote-hg tests; python not available'
18 if ! python
-c 'import mercurial'; then
19 skip_all
='skipping remote-hg tests; mercurial not available'
25 git clone
-q "hg::$1" $2
33 git push
-q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
36 (cd $2 && hg
-q update
)
43 git checkout
-q -b tmp
&&
44 git fetch
-q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
45 git checkout
-q @
{-1} &&
46 git branch
-q -D tmp
2> /dev
/null || true
51 hg
-R $1 log
--graph --debug
57 echo "username = A U Thor <author@example.com>"
59 echo "backout = -d \"0 0\""
60 echo "commit = -d \"0 0\""
61 echo "debugrawcommit = -d \"0 0\""
62 echo "tag = -d \"0 0\""
66 git config
--global remote-hg.hg-git-compat true
67 git config
--global remote-hg.track-branches true
69 HGEDITOR
=/usr
/bin
/true
70 GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
71 GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
72 export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
77 test_expect_success
'encoding' '
78 test_when_finished "rm -rf gitrepo* hgrepo*" &&
81 git init -q gitrepo &&
86 git commit -m "add älphà" &&
88 GIT_AUTHOR_NAME="tést èncödîng" &&
89 export GIT_AUTHOR_NAME &&
92 git commit -m "add beta" &&
96 git commit -m "add gämmâ" &&
98 : TODO git config i18n.commitencoding latin-1 &&
101 git commit -m "add déltà"
104 hg_clone gitrepo hgrepo &&
105 git_clone hgrepo gitrepo2 &&
106 hg_clone gitrepo2 hgrepo2 &&
108 HGENCODING=utf-8 hg_log hgrepo > expected &&
109 HGENCODING=utf-8 hg_log hgrepo2 > actual &&
111 test_cmp expected actual
114 test_expect_success
'file removal' '
115 test_when_finished "rm -rf gitrepo* hgrepo*" &&
118 git init -q gitrepo &&
120 echo alpha > alpha &&
122 git commit -m "add alpha" &&
125 git commit -m "add beta"
127 echo blah > foo/bar &&
129 git commit -m "add foo" &&
131 git commit -m "remove alpha" &&
133 git commit -m "remove foo/bar"
136 hg_clone gitrepo hgrepo &&
137 git_clone hgrepo gitrepo2 &&
138 hg_clone gitrepo2 hgrepo2 &&
140 hg_log hgrepo > expected &&
141 hg_log hgrepo2 > actual &&
143 test_cmp expected actual
146 test_expect_success
'git tags' '
147 test_when_finished "rm -rf gitrepo* hgrepo*" &&
150 git init -q gitrepo &&
152 git config receive.denyCurrentBranch ignore &&
153 echo alpha > alpha &&
155 git commit -m "add alpha" &&
160 git commit -m "add beta" &&
161 git tag -a -m "added tag beta" beta
164 hg_clone gitrepo hgrepo &&
165 git_clone hgrepo gitrepo2 &&
166 hg_clone gitrepo2 hgrepo2 &&
168 hg_log hgrepo > expected &&
169 hg_log hgrepo2 > actual &&
171 test_cmp expected actual
174 test_expect_success
'hg branch' '
175 test_when_finished "rm -rf gitrepo* hgrepo*" &&
178 git init -q gitrepo &&
181 echo alpha > alpha &&
183 git commit -q -m "add alpha" &&
184 git checkout -q -b not-master
188 hg_clone gitrepo hgrepo &&
193 hg -q commit -m "rename alpha to beta" &&
194 hg branch gamma | grep -v "permanent and global" &&
195 hg -q commit -m "started branch gamma"
198 hg_push hgrepo gitrepo &&
199 hg_clone gitrepo hgrepo2 &&
201 : Back to the common revision &&
202 (cd hgrepo && hg checkout default) &&
204 hg_log hgrepo > expected &&
205 hg_log hgrepo2 > actual &&
207 test_cmp expected actual
210 test_expect_success
'hg tags' '
211 test_when_finished "rm -rf gitrepo* hgrepo*" &&
214 git init -q gitrepo &&
217 echo alpha > alpha &&
219 git commit -m "add alpha" &&
220 git checkout -q -b not-master
224 hg_clone gitrepo hgrepo &&
231 hg_push hgrepo gitrepo &&
232 hg_clone gitrepo hgrepo2 &&
234 hg_log hgrepo > expected &&
235 hg_log hgrepo2 > actual &&
237 test_cmp expected actual