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 -c 'import mercurial'; then
19 skip_all='skipping remote-hg tests; mercurial not available'
23 if ! python -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
105 git config --global remote-hg.track-branches false
110 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
111 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
112 export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
117 test_expect_success 'executable bit' '
118 mkdir -p tmp && cd tmp &&
119 test_when_finished "cd .. && rm -rf tmp" &&
122 git init -q gitrepo &&
124 echo alpha > alpha &&
127 git commit -m "add alpha" &&
130 git commit -m "set executable bit" &&
133 git commit -m "clear executable bit"
138 hg_clone_$x gitrepo hgrepo-$x &&
141 hg manifest -r 1 -v &&
145 git_clone_$x hgrepo-$x gitrepo2-$x &&
146 git_log gitrepo2-$x > log-$x
149 test_cmp output-hg output-git &&
150 test_cmp log-hg log-git
153 test_expect_success 'symlink' '
154 mkdir -p tmp && cd tmp &&
155 test_when_finished "cd .. && rm -rf tmp" &&
158 git init -q gitrepo &&
160 echo alpha > alpha &&
162 git commit -m "add alpha" &&
165 git commit -m "add beta"
170 hg_clone_$x gitrepo hgrepo-$x &&
176 git_clone_$x hgrepo-$x gitrepo2-$x &&
177 git_log gitrepo2-$x > log-$x
180 test_cmp output-hg output-git &&
181 test_cmp log-hg log-git
184 test_expect_success 'merge conflict 1' '
185 mkdir -p tmp && cd tmp &&
186 test_when_finished "cd .. && rm -rf tmp" &&
204 hg resolve -m afile &&
205 hg ci -m "merge to C"
209 git_clone_$x hgrepo1 gitrepo-$x &&
210 hg_clone_$x gitrepo-$x hgrepo2-$x &&
211 hg_log hgrepo2-$x > hg-log-$x &&
212 git_log gitrepo-$x > git-log-$x
215 test_cmp hg-log-hg hg-log-git &&
216 test_cmp git-log-hg git-log-git
219 test_expect_success 'merge conflict 2' '
220 mkdir -p tmp && cd tmp &&
221 test_when_finished "cd .. && rm -rf tmp" &&
237 hg merge -r1 || true &&
239 hg resolve -m afile &&
240 hg ci -m "merge to B"
244 git_clone_$x hgrepo1 gitrepo-$x &&
245 hg_clone_$x gitrepo-$x hgrepo2-$x &&
246 hg_log hgrepo2-$x > hg-log-$x &&
247 git_log gitrepo-$x > git-log-$x
250 test_cmp hg-log-hg hg-log-git &&
251 test_cmp git-log-hg git-log-git
254 test_expect_success 'converged merge' '
255 mkdir -p tmp && cd tmp &&
256 test_when_finished "cd .. && rm -rf tmp" &&
275 hg merge -r2 || true &&
280 git_clone_$x hgrepo1 gitrepo-$x &&
281 hg_clone_$x gitrepo-$x hgrepo2-$x &&
282 hg_log hgrepo2-$x > hg-log-$x &&
283 git_log gitrepo-$x > git-log-$x
286 test_cmp hg-log-hg hg-log-git &&
287 test_cmp git-log-hg git-log-git
290 test_expect_success 'encoding' '
291 mkdir -p tmp && cd tmp &&
292 test_when_finished "cd .. && rm -rf tmp" &&
295 git init -q gitrepo &&
298 echo alpha > alpha &&
300 git commit -m "add älphà" &&
302 GIT_AUTHOR_NAME="tést èncödîng" &&
303 export GIT_AUTHOR_NAME &&
306 git commit -m "add beta" &&
308 echo gamma > gamma &&
310 git commit -m "add gämmâ" &&
312 : TODO git config i18n.commitencoding latin-1 &&
313 echo delta > delta &&
315 git commit -m "add déltà"
319 hg_clone_$x gitrepo hgrepo-$x &&
320 git_clone_$x hgrepo-$x gitrepo2-$x &&
322 HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
323 git_log gitrepo2-$x > git-log-$x
326 test_cmp hg-log-hg hg-log-git &&
327 test_cmp git-log-hg git-log-git
330 test_expect_success 'file removal' '
331 mkdir -p tmp && cd tmp &&
332 test_when_finished "cd .. && rm -rf tmp" &&
335 git init -q gitrepo &&
337 echo alpha > alpha &&
339 git commit -m "add alpha" &&
342 git commit -m "add beta"
344 echo blah > foo/bar &&
346 git commit -m "add foo" &&
348 git commit -m "remove alpha" &&
350 git commit -m "remove foo/bar"
355 hg_clone_$x gitrepo hgrepo-$x &&
362 git_clone_$x hgrepo-$x gitrepo2-$x &&
363 git_log gitrepo2-$x > log-$x
366 test_cmp output-hg output-git &&
367 test_cmp log-hg log-git
370 test_expect_success 'git tags' '
371 mkdir -p tmp && cd tmp &&
372 test_when_finished "cd .. && rm -rf tmp" &&
375 git init -q gitrepo &&
377 git config receive.denyCurrentBranch ignore &&
378 echo alpha > alpha &&
380 git commit -m "add alpha" &&
385 git commit -m "add beta" &&
386 git tag -a -m "added tag beta" beta
390 hg_clone_$x gitrepo hgrepo-$x &&
391 hg_log hgrepo-$x > log-$x
394 test_cmp log-hg log-git
397 test_expect_success 'hg author' '
398 mkdir -p tmp && cd tmp &&
399 test_when_finished "cd .. && rm -rf tmp" &&
403 git init -q gitrepo-$x &&
406 echo alpha > alpha &&
408 git commit -m "add alpha" &&
409 git checkout -q -b not-master
413 hg_clone_$x gitrepo-$x hgrepo-$x &&
419 hg commit -u "test" -m "add beta" &&
421 echo gamma >> beta &&
422 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
424 echo gamma > gamma &&
426 hg commit -u "<test@example.com>" -m "add gamma" &&
428 echo delta > delta &&
430 hg commit -u "name<test@example.com>" -m "add delta" &&
432 echo epsilon > epsilon &&
434 hg commit -u "name <test@example.com" -m "add epsilon" &&
438 hg commit -u " test " -m "add zeta" &&
442 hg commit -u "test < test@example.com >" -m "add eta" &&
444 echo theta > theta &&
446 hg commit -u "test >test@example.com>" -m "add theta" &&
450 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
453 hg_push_$x hgrepo-$x gitrepo-$x &&
454 hg_clone_$x gitrepo-$x hgrepo2-$x &&
456 hg_log hgrepo2-$x > hg-log-$x &&
457 git_log gitrepo-$x > git-log-$x
460 test_cmp hg-log-hg hg-log-git &&
461 test_cmp git-log-hg git-log-git
464 test_expect_success 'hg branch' '
465 mkdir -p tmp && cd tmp &&
466 test_when_finished "cd .. && rm -rf tmp" &&
470 git init -q gitrepo-$x &&
473 echo alpha > alpha &&
475 git commit -q -m "add alpha" &&
476 git checkout -q -b not-master
480 hg_clone_$x gitrepo-$x hgrepo-$x &&
485 hg -q commit -m "rename alpha to beta" &&
486 hg branch gamma | grep -v "permanent and global" &&
487 hg -q commit -m "started branch gamma"
490 hg_push_$x hgrepo-$x gitrepo-$x &&
491 hg_clone_$x gitrepo-$x hgrepo2-$x &&
493 hg_log hgrepo2-$x > hg-log-$x &&
494 git_log gitrepo-$x > git-log-$x
497 test_cmp hg-log-hg hg-log-git &&
498 test_cmp git-log-hg git-log-git
501 test_expect_success 'hg tags' '
502 mkdir -p tmp && cd tmp &&
503 test_when_finished "cd .. && rm -rf tmp" &&
507 git init -q gitrepo-$x &&
510 echo alpha > alpha &&
512 git commit -m "add alpha" &&
513 git checkout -q -b not-master
517 hg_clone_$x gitrepo-$x hgrepo-$x &&
524 hg_push_$x hgrepo-$x gitrepo-$x &&
525 hg_clone_$x gitrepo-$x hgrepo2-$x &&
528 git --git-dir=gitrepo-$x/.git tag -l &&
530 cat hgrepo2-$x/.hgtags
534 test_cmp output-hg output-git