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 'executable bit' '
113 mkdir -p tmp && cd tmp &&
114 test_when_finished "cd .. && rm -rf tmp" &&
117 git init -q gitrepo &&
119 echo alpha > alpha &&
122 git commit -m "add alpha" &&
125 git commit -m "set executable bit" &&
128 git commit -m "clear executable bit"
133 hg_clone_$x gitrepo hgrepo-$x &&
136 hg manifest -r 1 -v &&
140 git_clone_$x hgrepo-$x gitrepo2-$x &&
141 git_log gitrepo2-$x > log-$x
143 cp -r log-* output-* /tmp/foo/ &&
145 test_cmp output-hg output-git &&
146 test_cmp log-hg log-git
149 test_expect_success 'symlink' '
150 mkdir -p tmp && cd tmp &&
151 test_when_finished "cd .. && rm -rf tmp" &&
154 git init -q gitrepo &&
156 echo alpha > alpha &&
158 git commit -m "add alpha" &&
161 git commit -m "add beta"
166 hg_clone_$x gitrepo hgrepo-$x &&
172 git_clone_$x hgrepo-$x gitrepo2-$x &&
173 git_log gitrepo2-$x > log-$x
176 test_cmp output-hg output-git &&
177 test_cmp log-hg log-git
180 test_expect_success 'merge conflict 1' '
181 mkdir -p tmp && cd tmp &&
182 test_when_finished "cd .. && rm -rf tmp" &&
198 hg merge -r1 || true &&
200 hg resolve -m afile &&
201 hg ci -m "merge to C"
205 git_clone_$x hgrepo1 gitrepo-$x &&
206 hg_clone_$x gitrepo-$x hgrepo2-$x &&
207 hg_log hgrepo2-$x > hg-log-$x &&
208 git_log gitrepo-$x > git-log-$x
211 test_cmp hg-log-hg hg-log-git &&
212 test_cmp git-log-hg git-log-git
215 test_expect_success 'merge conflict 2' '
216 mkdir -p tmp && cd tmp &&
217 test_when_finished "cd .. && rm -rf tmp" &&
233 hg merge -r1 || true &&
235 hg resolve -m afile &&
236 hg ci -m "merge to B"
240 git_clone_$x hgrepo1 gitrepo-$x &&
241 hg_clone_$x gitrepo-$x hgrepo2-$x &&
242 hg_log hgrepo2-$x > hg-log-$x &&
243 git_log gitrepo-$x > git-log-$x
246 test_cmp hg-log-hg hg-log-git &&
247 test_cmp git-log-hg git-log-git
250 test_expect_success 'converged merge' '
251 mkdir -p tmp && cd tmp &&
252 test_when_finished "cd .. && rm -rf tmp" &&
271 hg merge -r2 || true &&
276 git_clone_$x hgrepo1 gitrepo-$x &&
277 hg_clone_$x gitrepo-$x hgrepo2-$x &&
278 hg_log hgrepo2-$x > hg-log-$x &&
279 git_log gitrepo-$x > git-log-$x
282 test_cmp hg-log-hg hg-log-git &&
283 test_cmp git-log-hg git-log-git
286 test_expect_success 'encoding' '
287 mkdir -p tmp && cd tmp &&
288 test_when_finished "cd .. && rm -rf tmp" &&
291 git init -q gitrepo &&
294 echo alpha > alpha &&
296 git commit -m "add älphà" &&
298 export GIT_AUTHOR_NAME="tést èncödîng" &&
301 git commit -m "add beta" &&
303 echo gamma > gamma &&
305 git commit -m "add gämmâ" &&
307 : TODO git config i18n.commitencoding latin-1 &&
308 echo delta > delta &&
310 git commit -m "add déltà"
314 hg_clone_$x gitrepo hgrepo-$x &&
315 git_clone_$x hgrepo-$x gitrepo2-$x &&
317 HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
318 git_log gitrepo2-$x > git-log-$x
321 test_cmp hg-log-hg hg-log-git &&
322 test_cmp git-log-hg git-log-git
325 test_expect_success 'file removal' '
326 mkdir -p tmp && cd tmp &&
327 test_when_finished "cd .. && rm -rf tmp" &&
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 mkdir -p tmp && cd tmp &&
367 test_when_finished "cd .. && rm -rf tmp" &&
370 git init -q gitrepo &&
372 git config receive.denyCurrentBranch ignore &&
373 echo alpha > alpha &&
375 git commit -m "add alpha" &&
380 git commit -m "add beta" &&
381 git tag -a -m "added tag beta" beta
385 hg_clone_$x gitrepo hgrepo-$x &&
386 hg_log hgrepo-$x > log-$x
389 test_cmp log-hg log-git
392 test_expect_success 'hg author' '
393 mkdir -p tmp && cd tmp &&
394 test_when_finished "cd .. && rm -rf tmp" &&
398 git init -q gitrepo-$x &&
401 echo alpha > alpha &&
403 git commit -m "add alpha" &&
404 git checkout -q -b not-master
408 hg_clone_$x gitrepo-$x hgrepo-$x &&
414 hg commit -u "test" -m "add beta" &&
416 echo gamma >> beta &&
417 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
419 echo gamma > gamma &&
421 hg commit -u "<test@example.com>" -m "add gamma" &&
423 echo delta > delta &&
425 hg commit -u "name<test@example.com>" -m "add delta" &&
427 echo epsilon > epsilon &&
429 hg commit -u "name <test@example.com" -m "add epsilon" &&
433 hg commit -u " test " -m "add zeta" &&
437 hg commit -u "test < test@example.com >" -m "add eta" &&
439 echo theta > theta &&
441 hg commit -u "test >test@example.com>" -m "add theta" &&
445 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
448 hg_push_$x hgrepo-$x gitrepo-$x &&
449 hg_clone_$x gitrepo-$x hgrepo2-$x &&
451 hg_log hgrepo2-$x > hg-log-$x &&
452 git_log gitrepo-$x > git-log-$x
455 test_cmp git-log-hg git-log-git &&
457 test_cmp hg-log-hg hg-log-git &&
458 test_cmp git-log-hg git-log-git
461 test_expect_success 'hg branch' '
462 mkdir -p tmp && cd tmp &&
463 test_when_finished "cd .. && rm -rf tmp" &&
467 git init -q gitrepo-$x &&
470 echo alpha > alpha &&
472 git commit -q -m "add alpha" &&
473 git checkout -q -b not-master
477 hg_clone_$x gitrepo-$x hgrepo-$x &&
482 hg -q commit -m "rename alpha to beta" &&
483 hg branch gamma | grep -v "permanent and global" &&
484 hg -q commit -m "started branch gamma"
487 hg_push_$x hgrepo-$x gitrepo-$x &&
488 hg_clone_$x gitrepo-$x hgrepo2-$x &&
490 hg_log hgrepo2-$x > hg-log-$x &&
491 git_log gitrepo-$x > git-log-$x
494 test_cmp hg-log-hg hg-log-git &&
495 test_cmp git-log-hg git-log-git
498 test_expect_success 'hg tags' '
499 mkdir -p tmp && cd tmp &&
500 test_when_finished "cd .. && rm -rf tmp" &&
504 git init -q gitrepo-$x &&
507 echo alpha > alpha &&
509 git commit -m "add alpha" &&
510 git checkout -q -b not-master
514 hg_clone_$x gitrepo-$x hgrepo-$x &&
521 hg_push_$x hgrepo-$x gitrepo-$x &&
522 hg_clone_$x gitrepo-$x hgrepo2-$x &&
525 git --git-dir=gitrepo-$x/.git tag -l &&
527 cat hgrepo2-$x/.hgtags
531 test_cmp output-hg output-git