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 git clone -q "hg::$PWD/$1" $2
33 # clone to an hg repo with git
37 hg -R $2 bookmark -i master &&
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 -i -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 >log &&
82 grep -v 'tag: *default/' log
86 git --git-dir=$1/.git fast-export --branches
92 echo "username = A U Thor <author@example.com>"
94 echo "backout = -d \"0 0\""
95 echo "commit = -d \"0 0\""
96 echo "debugrawcommit = -d \"0 0\""
97 echo "tag = -d \"0 0\""
99 echo "hgext.bookmarks ="
102 ) >> "$HOME"/.hgrc &&
103 git config --global receive.denycurrentbranch warn
104 git config --global remote-hg.hg-git-compat true
106 export HGEDITOR=/usr/bin/true
108 export GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
109 export GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
114 test_expect_success 'executable bit' '
115 mkdir -p tmp && cd tmp &&
116 test_when_finished "cd .. && rm -rf tmp" &&
119 git init -q gitrepo &&
121 echo alpha > alpha &&
124 git commit -m "add alpha" &&
127 git commit -m "set executable bit" &&
130 git commit -m "clear executable bit"
135 hg_clone_$x gitrepo hgrepo-$x &&
138 hg manifest -r 1 -v &&
142 git_clone_$x hgrepo-$x gitrepo2-$x &&
143 git_log gitrepo2-$x > log-$x
146 test_cmp output-hg output-git &&
147 test_cmp log-hg log-git
150 test_expect_success 'symlink' '
151 mkdir -p tmp && cd tmp &&
152 test_when_finished "cd .. && rm -rf tmp" &&
155 git init -q gitrepo &&
157 echo alpha > alpha &&
159 git commit -m "add alpha" &&
162 git commit -m "add beta"
167 hg_clone_$x gitrepo hgrepo-$x &&
173 git_clone_$x hgrepo-$x gitrepo2-$x &&
174 git_log gitrepo2-$x > log-$x
177 test_cmp output-hg output-git &&
178 test_cmp log-hg log-git
181 test_expect_success 'merge conflict 1' '
182 mkdir -p tmp && cd tmp &&
183 test_when_finished "cd .. && rm -rf tmp" &&
199 hg merge -r1 || true &&
201 hg resolve -m afile &&
202 hg ci -m "merge to C"
206 git_clone_$x hgrepo1 gitrepo-$x &&
207 hg_clone_$x gitrepo-$x hgrepo2-$x &&
208 hg_log hgrepo2-$x > hg-log-$x &&
209 git_log gitrepo-$x > git-log-$x
212 test_cmp hg-log-hg hg-log-git &&
213 test_cmp git-log-hg git-log-git
216 test_expect_success 'merge conflict 2' '
217 mkdir -p tmp && cd tmp &&
218 test_when_finished "cd .. && rm -rf tmp" &&
234 hg merge -r1 || true &&
236 hg resolve -m afile &&
237 hg ci -m "merge to B"
241 git_clone_$x hgrepo1 gitrepo-$x &&
242 hg_clone_$x gitrepo-$x hgrepo2-$x &&
243 hg_log hgrepo2-$x > hg-log-$x &&
244 git_log gitrepo-$x > git-log-$x
247 test_cmp hg-log-hg hg-log-git &&
248 test_cmp git-log-hg git-log-git
251 test_expect_success 'converged merge' '
252 mkdir -p tmp && cd tmp &&
253 test_when_finished "cd .. && rm -rf tmp" &&
272 hg merge -r2 || true &&
277 git_clone_$x hgrepo1 gitrepo-$x &&
278 hg_clone_$x gitrepo-$x hgrepo2-$x &&
279 hg_log hgrepo2-$x > hg-log-$x &&
280 git_log gitrepo-$x > git-log-$x
283 test_cmp hg-log-hg hg-log-git &&
284 test_cmp git-log-hg git-log-git
287 test_expect_success 'encoding' '
288 mkdir -p tmp && cd tmp &&
289 test_when_finished "cd .. && rm -rf tmp" &&
292 git init -q gitrepo &&
295 echo alpha > alpha &&
297 git commit -m "add älphà" &&
299 export GIT_AUTHOR_NAME="tést èncödîng" &&
302 git commit -m "add beta" &&
304 echo gamma > gamma &&
306 git commit -m "add gämmâ" &&
308 : TODO git config i18n.commitencoding latin-1 &&
309 echo delta > delta &&
311 git commit -m "add déltà"
315 hg_clone_$x gitrepo hgrepo-$x &&
316 git_clone_$x hgrepo-$x gitrepo2-$x &&
318 HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
319 git_log gitrepo2-$x > git-log-$x
322 test_cmp hg-log-hg hg-log-git &&
323 test_cmp git-log-hg git-log-git
326 test_expect_success 'file removal' '
327 mkdir -p tmp && cd tmp &&
328 test_when_finished "cd .. && rm -rf tmp" &&
331 git init -q gitrepo &&
333 echo alpha > alpha &&
335 git commit -m "add alpha" &&
338 git commit -m "add beta"
340 echo blah > foo/bar &&
342 git commit -m "add foo" &&
344 git commit -m "remove alpha" &&
346 git commit -m "remove foo/bar"
351 hg_clone_$x gitrepo hgrepo-$x &&
358 git_clone_$x hgrepo-$x gitrepo2-$x &&
359 git_log gitrepo2-$x > log-$x
362 test_cmp output-hg output-git &&
363 test_cmp log-hg log-git
366 test_expect_success 'git tags' '
367 mkdir -p tmp && cd tmp &&
368 test_when_finished "cd .. && rm -rf tmp" &&
371 git init -q gitrepo &&
373 git config receive.denyCurrentBranch ignore &&
374 echo alpha > alpha &&
376 git commit -m "add alpha" &&
381 git commit -m "add beta" &&
382 git tag -a -m "added tag beta" beta
386 hg_clone_$x gitrepo hgrepo-$x &&
387 hg_log hgrepo-$x > log-$x
390 test_cmp log-hg log-git
393 test_expect_success 'hg author' '
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 -m "add alpha" &&
405 git checkout -q -b not-master
409 hg_clone_$x gitrepo-$x hgrepo-$x &&
415 hg commit -u "test" -m "add beta" &&
417 echo gamma >> beta &&
418 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
420 echo gamma > gamma &&
422 hg commit -u "<test@example.com>" -m "add gamma" &&
424 echo delta > delta &&
426 hg commit -u "name<test@example.com>" -m "add delta" &&
428 echo epsilon > epsilon &&
430 hg commit -u "name <test@example.com" -m "add epsilon" &&
434 hg commit -u " test " -m "add zeta" &&
438 hg commit -u "test < test@example.com >" -m "add eta" &&
440 echo theta > theta &&
442 hg commit -u "test >test@example.com>" -m "add theta" &&
446 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
449 hg_push_$x hgrepo-$x gitrepo-$x &&
450 hg_clone_$x gitrepo-$x hgrepo2-$x &&
452 hg_log hgrepo2-$x > hg-log-$x &&
453 git_log gitrepo-$x > git-log-$x
456 test_cmp git-log-hg git-log-git &&
458 test_cmp hg-log-hg hg-log-git &&
459 test_cmp git-log-hg git-log-git
462 test_expect_success 'hg branch' '
463 mkdir -p tmp && cd tmp &&
464 test_when_finished "cd .. && rm -rf tmp" &&
468 git init -q gitrepo-$x &&
471 echo alpha > alpha &&
473 git commit -q -m "add alpha" &&
474 git checkout -q -b not-master
478 hg_clone_$x gitrepo-$x hgrepo-$x &&
483 hg -q commit -m "rename alpha to beta" &&
484 hg branch gamma | grep -v "permanent and global" &&
485 hg -q commit -m "started branch gamma"
488 hg_push_$x hgrepo-$x gitrepo-$x &&
489 hg_clone_$x gitrepo-$x hgrepo2-$x &&
491 hg_log hgrepo2-$x > hg-log-$x &&
492 git_log gitrepo-$x > git-log-$x
495 test_cmp hg-log-hg hg-log-git &&
496 test_cmp git-log-hg git-log-git
499 test_expect_success 'hg tags' '
500 mkdir -p tmp && cd tmp &&
501 test_when_finished "cd .. && rm -rf tmp" &&
505 git init -q gitrepo-$x &&
508 echo alpha > alpha &&
510 git commit -m "add alpha" &&
511 git checkout -q -b not-master
515 hg_clone_$x gitrepo-$x hgrepo-$x &&
522 hg_push_$x hgrepo-$x gitrepo-$x &&
523 hg_clone_$x gitrepo-$x hgrepo2-$x &&
526 git --git-dir=gitrepo-$x/.git tag -l &&
528 cat hgrepo2-$x/.hgtags
532 test_cmp output-hg output-git