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 biridectionality of remote-hg'
13 if ! test_have_prereq PYTHON
; then
14 skip_all
='skipping remote-hg tests; python not available'
18 if ! "$PYTHON_PATH" -c 'import mercurial'; then
19 skip_all
='skipping remote-hg tests; mercurial not available'
25 hg
-R $1 bookmark
-f -r tip master
&&
26 git clone
-q "hg::$PWD/$1" $2
34 git push
-q "hg::$PWD/../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
37 (cd $2 && hg
-q update
)
44 old
=$
(git symbolic-ref
--short HEAD
)
45 git checkout
-q -b tmp
&&
46 git fetch
-q "hg::$PWD/../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
47 git checkout
-q $old &&
48 git branch
-q -D tmp
2> /dev
/null || true
53 hg
-R $1 log
--graph --debug |
grep -v 'tag: *default/'
59 echo "username = A U Thor <author@example.com>"
61 echo "backout = -d \"0 0\""
62 echo "commit = -d \"0 0\""
63 echo "debugrawcommit = -d \"0 0\""
64 echo "tag = -d \"0 0\""
66 git config
--global remote-hg.hg-git-compat true
68 export HGEDITOR
=/usr
/bin
/true
70 export GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
71 export GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
76 test_expect_success
'encoding' '
77 mkdir -p tmp && cd tmp &&
78 test_when_finished "cd .. && rm -rf tmp" &&
81 git init -q gitrepo &&
86 git commit -m "add älphà" &&
88 export GIT_AUTHOR_NAME="tést èncödîng" &&
91 git commit -m "add beta" &&
95 git commit -m "add gämmâ" &&
97 : TODO git config i18n.commitencoding latin-1 &&
100 git commit -m "add déltà"
103 hg_clone gitrepo hgrepo &&
104 git_clone hgrepo gitrepo2 &&
105 hg_clone gitrepo2 hgrepo2 &&
107 HGENCODING=utf-8 hg_log hgrepo > expected &&
108 HGENCODING=utf-8 hg_log hgrepo2 > actual &&
110 test_cmp expected actual
113 test_expect_success
'file removal' '
114 mkdir -p tmp && cd tmp &&
115 test_when_finished "cd .. && rm -rf tmp" &&
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 mkdir -p tmp && cd tmp &&
148 test_when_finished "cd .. && rm -rf tmp" &&
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 mkdir -p tmp && cd tmp &&
177 test_when_finished "cd .. && rm -rf tmp" &&
180 git init -q gitrepo &&
183 echo alpha > alpha &&
185 git commit -q -m "add alpha" &&
186 git checkout -q -b not-master
190 hg_clone gitrepo hgrepo &&
195 hg -q commit -m "rename alpha to beta" &&
196 hg branch gamma | grep -v "permanent and global" &&
197 hg -q commit -m "started branch gamma"
200 hg_push hgrepo gitrepo &&
201 hg_clone gitrepo hgrepo2 &&
203 : TODO, avoid "master" bookmark &&
204 (cd hgrepo2 && hg checkout gamma) &&
206 hg_log hgrepo > expected &&
207 hg_log hgrepo2 > actual &&
209 test_cmp expected actual
212 test_expect_success
'hg tags' '
213 mkdir -p tmp && cd tmp &&
214 test_when_finished "cd .. && rm -rf tmp" &&
217 git init -q gitrepo &&
220 echo alpha > alpha &&
222 git commit -m "add alpha" &&
223 git checkout -q -b not-master
227 hg_clone gitrepo hgrepo &&
234 hg_push hgrepo gitrepo &&
235 hg_clone gitrepo hgrepo2 &&
237 hg_log hgrepo > expected &&
238 hg_log hgrepo2 > actual &&
240 test_cmp expected actual