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'
11 test -z "$TEST_DIRECTORY" && TEST_DIRECTORY="$PWD/.."
12 . "$TEST_DIRECTORY"/test-lib.sh
14 if ! test_have_prereq PYTHON; then
15 skip_all='skipping remote-hg tests; python not available'
19 if ! "$PYTHON_PATH" -c 'import mercurial'; then
20 skip_all='skipping remote-hg tests; mercurial not available'
24 if ! "$PYTHON_PATH" -c 'import hggit'; then
25 skip_all='skipping remote-hg tests; hg-git not available'
29 # clone to a git repo with git
31 git clone -q "hg::$1" $2 &&
32 (cd $2 && git checkout master && git branch -D default)
35 # clone to an hg repo with git
39 hg -R $2 bookmark -i master &&
41 git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
44 (cd $2 && hg -q update)
47 # clone to a git repo with hg
52 hg bookmark -i -f -r tip master &&
53 hg -q push -r master ../$2 || true
57 # clone to an hg repo with hg
62 # push an hg repo with git
66 git checkout -q -b tmp &&
67 git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
68 git branch -D default &&
69 git checkout -q @{-1} &&
70 git branch -q -D tmp 2> /dev/null || true
74 # push an hg git repo with hg
78 hg -q push ../$2 || true
83 hg -R $1 log --graph --debug >log &&
84 grep -v 'tag: *default/' log
88 git --git-dir=$1/.git fast-export --branches
94 echo "username = A U Thor <author@example.com>"
96 echo "backout = -d \"0 0\""
97 echo "commit = -d \"0 0\""
98 echo "debugrawcommit = -d \"0 0\""
99 echo "tag = -d \"0 0\""
101 echo "hgext.bookmarks ="
104 ) >> "$HOME"/.hgrc &&
105 git config --global receive.denycurrentbranch warn
106 git config --global remote-hg.hg-git-compat true
107 git config --global remote-hg.track-branches false
112 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
113 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
114 export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
119 test_expect_success 'executable bit' '
120 test_when_finished "rm -rf gitrepo* hgrepo*" &&
123 git init -q gitrepo &&
125 echo alpha > alpha &&
128 git commit -m "add alpha" &&
131 git commit -m "set executable bit" &&
134 git commit -m "clear executable bit"
139 hg_clone_$x gitrepo hgrepo-$x &&
142 hg manifest -r 1 -v &&
146 git_clone_$x hgrepo-$x gitrepo2-$x &&
147 git_log gitrepo2-$x > log-$x
150 test_cmp output-hg output-git &&
151 test_cmp log-hg log-git
154 test_expect_success 'symlink' '
155 test_when_finished "rm -rf gitrepo* hgrepo*" &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
203 hg resolve -m afile &&
204 hg ci -m "merge to C"
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 'merge conflict 2' '
219 test_when_finished "rm -rf gitrepo* hgrepo*" &&
235 hg merge -r1 || true &&
237 hg resolve -m afile &&
238 hg ci -m "merge to B"
242 git_clone_$x hgrepo1 gitrepo-$x &&
243 hg_clone_$x gitrepo-$x hgrepo2-$x &&
244 hg_log hgrepo2-$x > hg-log-$x &&
245 git_log gitrepo-$x > git-log-$x
248 test_cmp hg-log-hg hg-log-git &&
249 test_cmp git-log-hg git-log-git
252 test_expect_success 'converged merge' '
253 test_when_finished "rm -rf gitrepo* hgrepo*" &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
291 git init -q gitrepo &&
294 echo alpha > alpha &&
296 git commit -m "add älphà" &&
298 GIT_AUTHOR_NAME="tést èncödîng" &&
299 export GIT_AUTHOR_NAME &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
330 git init -q gitrepo &&
332 echo alpha > alpha &&
334 git commit -m "add alpha" &&
337 git commit -m "add beta"
339 echo blah > foo/bar &&
341 git commit -m "add foo" &&
343 git commit -m "remove alpha" &&
345 git commit -m "remove foo/bar"
350 hg_clone_$x gitrepo hgrepo-$x &&
357 git_clone_$x hgrepo-$x gitrepo2-$x &&
358 git_log gitrepo2-$x > log-$x
361 test_cmp output-hg output-git &&
362 test_cmp log-hg log-git
365 test_expect_success 'git tags' '
366 test_when_finished "rm -rf gitrepo* hgrepo*" &&
369 git init -q gitrepo &&
371 git config receive.denyCurrentBranch ignore &&
372 echo alpha > alpha &&
374 git commit -m "add alpha" &&
379 git commit -m "add beta" &&
380 git tag -a -m "added tag beta" beta
384 hg_clone_$x gitrepo hgrepo-$x &&
385 hg_log hgrepo-$x > log-$x
388 test_cmp log-hg log-git
391 test_expect_success 'hg author' '
392 test_when_finished "rm -rf gitrepo* hgrepo*" &&
396 git init -q gitrepo-$x &&
399 echo alpha > alpha &&
401 git commit -m "add alpha" &&
402 git checkout -q -b not-master
406 hg_clone_$x gitrepo-$x hgrepo-$x &&
412 hg commit -u "test" -m "add beta" &&
414 echo gamma >> beta &&
415 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
417 echo gamma > gamma &&
419 hg commit -u "<test@example.com>" -m "add gamma" &&
421 echo delta > delta &&
423 hg commit -u "name<test@example.com>" -m "add delta" &&
425 echo epsilon > epsilon &&
427 hg commit -u "name <test@example.com" -m "add epsilon" &&
431 hg commit -u " test " -m "add zeta" &&
435 hg commit -u "test < test@example.com >" -m "add eta" &&
437 echo theta > theta &&
439 hg commit -u "test >test@example.com>" -m "add theta" &&
443 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
446 hg_push_$x hgrepo-$x gitrepo-$x &&
447 hg_clone_$x gitrepo-$x hgrepo2-$x &&
449 hg_log hgrepo2-$x > hg-log-$x &&
450 git_log gitrepo-$x > git-log-$x
453 test_cmp hg-log-hg hg-log-git &&
454 test_cmp git-log-hg git-log-git
457 test_expect_success 'hg branch' '
458 test_when_finished "rm -rf gitrepo* hgrepo*" &&
462 git init -q gitrepo-$x &&
465 echo alpha > alpha &&
467 git commit -q -m "add alpha" &&
468 git checkout -q -b not-master
472 hg_clone_$x gitrepo-$x hgrepo-$x &&
477 hg -q commit -m "rename alpha to beta" &&
478 hg branch gamma | grep -v "permanent and global" &&
479 hg -q commit -m "started branch gamma"
482 hg_push_$x hgrepo-$x gitrepo-$x &&
483 hg_clone_$x gitrepo-$x hgrepo2-$x &&
485 hg_log hgrepo2-$x > hg-log-$x &&
486 git_log gitrepo-$x > git-log-$x
489 test_cmp hg-log-hg hg-log-git &&
490 test_cmp git-log-hg git-log-git
493 test_expect_success 'hg tags' '
494 test_when_finished "rm -rf gitrepo* hgrepo*" &&
498 git init -q gitrepo-$x &&
501 echo alpha > alpha &&
503 git commit -m "add alpha" &&
504 git checkout -q -b not-master
508 hg_clone_$x gitrepo-$x hgrepo-$x &&
515 hg_push_$x hgrepo-$x gitrepo-$x &&
516 hg_clone_$x gitrepo-$x hgrepo2-$x &&
519 git --git-dir=gitrepo-$x/.git tag -l &&
521 cat hgrepo2-$x/.hgtags
525 test_cmp output-hg output-git