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::$1" $2 &&
31 (cd $2 && git checkout master && git branch -D default)
34 # clone to an hg repo with git
38 hg -R $2 bookmark -i master &&
40 git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
43 (cd $2 && hg -q update)
46 # clone to a git repo with hg
51 hg bookmark -i -f -r tip master &&
52 hg -q push -r master ../$2 || true
56 # clone to an hg repo with hg
61 # push an hg repo with git
65 git checkout -q -b tmp &&
66 git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
67 git branch -D default &&
68 git checkout -q @{-1} &&
69 git branch -q -D tmp 2> /dev/null || true
73 # push an hg git repo with hg
77 hg -q push ../$2 || true
82 hg -R $1 log --graph --debug >log &&
83 grep -v 'tag: *default/' log
87 git --git-dir=$1/.git fast-export --branches
93 echo "username = A U Thor <author@example.com>"
95 echo "backout = -d \"0 0\""
96 echo "commit = -d \"0 0\""
97 echo "debugrawcommit = -d \"0 0\""
98 echo "tag = -d \"0 0\""
100 echo "hgext.bookmarks ="
103 ) >> "$HOME"/.hgrc &&
104 git config --global receive.denycurrentbranch warn
105 git config --global remote-hg.hg-git-compat true
106 git config --global remote-hg.track-branches false
111 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
112 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
113 export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
118 test_expect_success 'executable bit' '
119 test_when_finished "rm -rf gitrepo* hgrepo*" &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
157 git init -q gitrepo &&
159 echo alpha > alpha &&
161 git commit -m "add alpha" &&
164 git commit -m "add beta"
169 hg_clone_$x gitrepo hgrepo-$x &&
175 git_clone_$x hgrepo-$x gitrepo2-$x &&
176 git_log gitrepo2-$x > log-$x
179 test_cmp output-hg output-git &&
180 test_cmp log-hg log-git
183 test_expect_success 'merge conflict 1' '
184 test_when_finished "rm -rf gitrepo* hgrepo*" &&
202 hg resolve -m afile &&
203 hg ci -m "merge to C"
207 git_clone_$x hgrepo1 gitrepo-$x &&
208 hg_clone_$x gitrepo-$x hgrepo2-$x &&
209 hg_log hgrepo2-$x > hg-log-$x &&
210 git_log gitrepo-$x > git-log-$x
213 test_cmp hg-log-hg hg-log-git &&
214 test_cmp git-log-hg git-log-git
217 test_expect_success 'merge conflict 2' '
218 test_when_finished "rm -rf gitrepo* hgrepo*" &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
290 git init -q gitrepo &&
293 echo alpha > alpha &&
295 git commit -m "add älphà" &&
297 GIT_AUTHOR_NAME="tést èncödîng" &&
298 export GIT_AUTHOR_NAME &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
329 git init -q gitrepo &&
331 echo alpha > alpha &&
333 git commit -m "add alpha" &&
336 git commit -m "add beta"
338 echo blah > foo/bar &&
340 git commit -m "add foo" &&
342 git commit -m "remove alpha" &&
344 git commit -m "remove foo/bar"
349 hg_clone_$x gitrepo hgrepo-$x &&
356 git_clone_$x hgrepo-$x gitrepo2-$x &&
357 git_log gitrepo2-$x > log-$x
360 test_cmp output-hg output-git &&
361 test_cmp log-hg log-git
364 test_expect_success 'git tags' '
365 test_when_finished "rm -rf gitrepo* hgrepo*" &&
368 git init -q gitrepo &&
370 git config receive.denyCurrentBranch ignore &&
371 echo alpha > alpha &&
373 git commit -m "add alpha" &&
378 git commit -m "add beta" &&
379 git tag -a -m "added tag beta" beta
383 hg_clone_$x gitrepo hgrepo-$x &&
384 hg_log hgrepo-$x > log-$x
387 test_cmp log-hg log-git
390 test_expect_success 'hg author' '
391 test_when_finished "rm -rf gitrepo* hgrepo*" &&
395 git init -q gitrepo-$x &&
398 echo alpha > alpha &&
400 git commit -m "add alpha" &&
401 git checkout -q -b not-master
405 hg_clone_$x gitrepo-$x hgrepo-$x &&
411 hg commit -u "test" -m "add beta" &&
413 echo gamma >> beta &&
414 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
416 echo gamma > gamma &&
418 hg commit -u "<test@example.com>" -m "add gamma" &&
420 echo delta > delta &&
422 hg commit -u "name<test@example.com>" -m "add delta" &&
424 echo epsilon > epsilon &&
426 hg commit -u "name <test@example.com" -m "add epsilon" &&
430 hg commit -u " test " -m "add zeta" &&
434 hg commit -u "test < test@example.com >" -m "add eta" &&
436 echo theta > theta &&
438 hg commit -u "test >test@example.com>" -m "add theta" &&
442 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
445 hg_push_$x hgrepo-$x gitrepo-$x &&
446 hg_clone_$x gitrepo-$x hgrepo2-$x &&
448 hg_log hgrepo2-$x > hg-log-$x &&
449 git_log gitrepo-$x > git-log-$x
452 test_cmp hg-log-hg hg-log-git &&
453 test_cmp git-log-hg git-log-git
456 test_expect_success 'hg branch' '
457 test_when_finished "rm -rf gitrepo* hgrepo*" &&
461 git init -q gitrepo-$x &&
464 echo alpha > alpha &&
466 git commit -q -m "add alpha" &&
467 git checkout -q -b not-master
471 hg_clone_$x gitrepo-$x hgrepo-$x &&
476 hg -q commit -m "rename alpha to beta" &&
477 hg branch gamma | grep -v "permanent and global" &&
478 hg -q commit -m "started branch gamma"
481 hg_push_$x hgrepo-$x gitrepo-$x &&
482 hg_clone_$x gitrepo-$x hgrepo2-$x &&
484 hg_log hgrepo2-$x > hg-log-$x &&
485 git_log gitrepo-$x > git-log-$x
488 test_cmp hg-log-hg hg-log-git &&
489 test_cmp git-log-hg git-log-git
492 test_expect_success 'hg tags' '
493 test_when_finished "rm -rf gitrepo* hgrepo*" &&
497 git init -q gitrepo-$x &&
500 echo alpha > alpha &&
502 git commit -m "add alpha" &&
503 git checkout -q -b not-master
507 hg_clone_$x gitrepo-$x hgrepo-$x &&
514 hg_push_$x hgrepo-$x gitrepo-$x &&
515 hg_clone_$x gitrepo-$x hgrepo2-$x &&
518 git --git-dir=gitrepo-$x/.git tag -l &&
520 cat hgrepo2-$x/.hgtags
524 test_cmp output-hg output-git