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 remote-hg output compared to hg-git'
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'
23 if ! "$PYTHON_PATH" -c 'import hggit'; then
24 skip_all
='skipping remote-hg tests; hg-git not available'
28 # clone to a git repo with git
30 hg
-R $1 bookmark
-f -r tip master
&&
31 git clone
-q "hg::$PWD/$1" $2
34 # clone to an hg repo with git
39 git push
-q "hg::$PWD/../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
42 (cd $2 && hg
-q update
)
45 # clone to a git repo with hg
50 hg bookmark
-f -r tip master
&&
51 hg
-q push
-r master ..
/$2 || true
55 # clone to an hg repo with hg
60 # push an hg repo with git
64 old
=$
(git symbolic-ref
--short HEAD
)
65 git checkout
-q -b tmp
&&
66 git fetch
-q "hg::$PWD/../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
67 git checkout
-q $old &&
68 git branch
-q -D tmp
2> /dev
/null || true
72 # push an hg git repo with hg
76 hg
-q push ..
/$2 || true
81 hg
-R $1 log
--graph --debug |
grep -v 'tag: *default/'
85 git
--git-dir=$1/.git fast-export
--branches
91 echo "username = A U Thor <author@example.com>"
93 echo "backout = -d \"0 0\""
94 echo "commit = -d \"0 0\""
95 echo "debugrawcommit = -d \"0 0\""
96 echo "tag = -d \"0 0\""
98 echo "hgext.bookmarks ="
100 ) >> "$HOME"/.hgrc
&&
101 git config
--global receive.denycurrentbranch warn
102 git config
--global remote-hg.hg-git-compat true
104 export HGEDITOR
=/usr
/bin
/true
106 export GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
107 export GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
112 test_expect_success
'merge conflict 1' '
113 mkdir -p tmp && cd tmp &&
114 test_when_finished "cd .. && rm -rf tmp" &&
130 hg merge -r1 || true &&
132 hg resolve -m afile &&
133 hg ci -m "merge to C"
137 git_clone_$x hgrepo1 gitrepo-$x &&
138 hg_clone_$x gitrepo-$x hgrepo2-$x &&
139 hg_log hgrepo2-$x > hg-log-$x &&
140 git_log gitrepo-$x > git-log-$x
143 test_cmp hg-log-hg hg-log-git &&
144 test_cmp git-log-hg git-log-git
147 test_expect_success
'merge conflict 2' '
148 mkdir -p tmp && cd tmp &&
149 test_when_finished "cd .. && rm -rf tmp" &&
165 hg merge -r1 || true &&
167 hg resolve -m afile &&
168 hg ci -m "merge to B"
172 git_clone_$x hgrepo1 gitrepo-$x &&
173 hg_clone_$x gitrepo-$x hgrepo2-$x &&
174 hg_log hgrepo2-$x > hg-log-$x &&
175 git_log gitrepo-$x > git-log-$x
178 test_cmp hg-log-hg hg-log-git &&
179 test_cmp git-log-hg git-log-git
182 test_expect_success
'converged merge' '
183 mkdir -p tmp && cd tmp &&
184 test_when_finished "cd .. && rm -rf tmp" &&
203 hg merge -r2 || true &&
208 git_clone_$x hgrepo1 gitrepo-$x &&
209 hg_clone_$x gitrepo-$x hgrepo2-$x &&
210 hg_log hgrepo2-$x > hg-log-$x &&
211 git_log gitrepo-$x > git-log-$x
214 test_cmp hg-log-hg hg-log-git &&
215 test_cmp git-log-hg git-log-git
218 test_expect_success
'encoding' '
219 mkdir -p tmp && cd tmp &&
220 test_when_finished "cd .. && rm -rf tmp" &&
223 git init -q gitrepo &&
226 echo alpha > alpha &&
228 git commit -m "add älphà" &&
230 export GIT_AUTHOR_NAME="tést èncödîng" &&
233 git commit -m "add beta" &&
235 echo gamma > gamma &&
237 git commit -m "add gämmâ" &&
239 : TODO git config i18n.commitencoding latin-1 &&
240 echo delta > delta &&
242 git commit -m "add déltà"
246 hg_clone_$x gitrepo hgrepo-$x &&
247 git_clone_$x hgrepo-$x gitrepo2-$x &&
249 HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
250 git_log gitrepo2-$x > git-log-$x
253 test_cmp hg-log-hg hg-log-git &&
254 test_cmp git-log-hg git-log-git
257 test_expect_success
'file removal' '
258 mkdir -p tmp && cd tmp &&
259 test_when_finished "cd .. && rm -rf tmp" &&
262 git init -q gitrepo &&
264 echo alpha > alpha &&
266 git commit -m "add alpha" &&
269 git commit -m "add beta"
271 echo blah > foo/bar &&
273 git commit -m "add foo" &&
275 git commit -m "remove alpha" &&
277 git commit -m "remove foo/bar"
282 hg_clone_$x gitrepo hgrepo-$x &&
289 git_clone_$x hgrepo-$x gitrepo2-$x &&
290 git_log gitrepo2-$x > log-$x
293 test_cmp output-hg output-git &&
294 test_cmp log-hg log-git
297 test_expect_success
'git tags' '
298 mkdir -p tmp && cd tmp &&
299 test_when_finished "cd .. && rm -rf tmp" &&
302 git init -q gitrepo &&
304 git config receive.denyCurrentBranch ignore &&
305 echo alpha > alpha &&
307 git commit -m "add alpha" &&
312 git commit -m "add beta" &&
313 git tag -a -m "added tag beta" beta
317 hg_clone_$x gitrepo hgrepo-$x &&
318 hg_log hgrepo-$x > log-$x
321 test_cmp log-hg log-git
324 test_expect_success
'hg author' '
325 mkdir -p tmp && cd tmp &&
326 test_when_finished "cd .. && rm -rf tmp" &&
330 git init -q gitrepo-$x &&
333 echo alpha > alpha &&
335 git commit -m "add alpha" &&
336 git checkout -q -b not-master
340 hg_clone_$x gitrepo-$x hgrepo-$x &&
346 hg commit -u "test" -m "add beta" &&
348 echo gamma >> beta &&
349 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
351 echo gamma > gamma &&
353 hg commit -u "<test@example.com>" -m "add gamma" &&
355 echo delta > delta &&
357 hg commit -u "name<test@example.com>" -m "add delta" &&
359 echo epsilon > epsilon &&
361 hg commit -u "name <test@example.com" -m "add epsilon" &&
365 hg commit -u " test " -m "add zeta" &&
369 hg commit -u "test < test@example.com >" -m "add eta" &&
371 echo theta > theta &&
373 hg commit -u "test >test@example.com>" -m "add theta" &&
377 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
380 hg_push_$x hgrepo-$x gitrepo-$x &&
381 hg_clone_$x gitrepo-$x hgrepo2-$x &&
383 hg_log hgrepo2-$x > hg-log-$x &&
384 git_log gitrepo-$x > git-log-$x
387 test_cmp git-log-hg git-log-git &&
389 test_cmp hg-log-hg hg-log-git &&
390 test_cmp git-log-hg git-log-git
393 test_expect_success
'hg branch' '
394 mkdir -p tmp && cd tmp &&
395 test_when_finished "cd .. && rm -rf tmp" &&
399 git init -q gitrepo-$x &&
402 echo alpha > alpha &&
404 git commit -q -m "add alpha" &&
405 git checkout -q -b not-master
409 hg_clone_$x gitrepo-$x hgrepo-$x &&
414 hg -q commit -m "rename alpha to beta" &&
415 hg branch gamma | grep -v "permanent and global" &&
416 hg -q commit -m "started branch gamma"
419 hg_push_$x hgrepo-$x gitrepo-$x &&
420 hg_clone_$x gitrepo-$x hgrepo2-$x &&
422 hg_log hgrepo2-$x > hg-log-$x &&
423 git_log gitrepo-$x > git-log-$x
426 test_cmp hg-log-hg hg-log-git &&
427 test_cmp git-log-hg git-log-git
430 test_expect_success
'hg tags' '
431 mkdir -p tmp && cd tmp &&
432 test_when_finished "cd .. && rm -rf tmp" &&
436 git init -q gitrepo-$x &&
439 echo alpha > alpha &&
441 git commit -m "add alpha" &&
442 git checkout -q -b not-master
446 hg_clone_$x gitrepo-$x hgrepo-$x &&
453 hg_push_$x hgrepo-$x gitrepo-$x &&
454 hg_clone_$x gitrepo-$x hgrepo2-$x &&
457 git --git-dir=gitrepo-$x/.git tag -l &&
459 cat hgrepo2-$x/.hgtags
463 test_cmp output-hg output-git