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
105 git config --global remote-hg.track-branches false
107 HGEDITOR=/usr/bin/true
109 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
110 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
111 export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
116 test_expect_success 'executable bit' '
117 mkdir -p tmp && cd tmp &&
118 test_when_finished "cd .. && rm -rf tmp" &&
121 git init -q gitrepo &&
123 echo alpha > alpha &&
126 git commit -m "add alpha" &&
129 git commit -m "set executable bit" &&
132 git commit -m "clear executable bit"
137 hg_clone_$x gitrepo hgrepo-$x &&
140 hg manifest -r 1 -v &&
144 git_clone_$x hgrepo-$x gitrepo2-$x &&
145 git_log gitrepo2-$x > log-$x
148 test_cmp output-hg output-git &&
149 test_cmp log-hg log-git
152 test_expect_success 'symlink' '
153 mkdir -p tmp && cd tmp &&
154 test_when_finished "cd .. && rm -rf tmp" &&
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 mkdir -p tmp && cd tmp &&
185 test_when_finished "cd .. && rm -rf tmp" &&
201 hg merge -r1 || true &&
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 mkdir -p tmp && cd tmp &&
220 test_when_finished "cd .. && rm -rf tmp" &&
236 hg merge -r1 || true &&
238 hg resolve -m afile &&
239 hg ci -m "merge to B"
243 git_clone_$x hgrepo1 gitrepo-$x &&
244 hg_clone_$x gitrepo-$x hgrepo2-$x &&
245 hg_log hgrepo2-$x > hg-log-$x &&
246 git_log gitrepo-$x > git-log-$x
249 test_cmp hg-log-hg hg-log-git &&
250 test_cmp git-log-hg git-log-git
253 test_expect_success 'converged merge' '
254 mkdir -p tmp && cd tmp &&
255 test_when_finished "cd .. && rm -rf tmp" &&
274 hg merge -r2 || true &&
279 git_clone_$x hgrepo1 gitrepo-$x &&
280 hg_clone_$x gitrepo-$x hgrepo2-$x &&
281 hg_log hgrepo2-$x > hg-log-$x &&
282 git_log gitrepo-$x > git-log-$x
285 test_cmp hg-log-hg hg-log-git &&
286 test_cmp git-log-hg git-log-git
289 test_expect_success 'encoding' '
290 mkdir -p tmp && cd tmp &&
291 test_when_finished "cd .. && rm -rf tmp" &&
294 git init -q gitrepo &&
297 echo alpha > alpha &&
299 git commit -m "add älphà" &&
301 GIT_AUTHOR_NAME="tést èncödîng" &&
302 export GIT_AUTHOR_NAME &&
305 git commit -m "add beta" &&
307 echo gamma > gamma &&
309 git commit -m "add gämmâ" &&
311 : TODO git config i18n.commitencoding latin-1 &&
312 echo delta > delta &&
314 git commit -m "add déltà"
318 hg_clone_$x gitrepo hgrepo-$x &&
319 git_clone_$x hgrepo-$x gitrepo2-$x &&
321 HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
322 git_log gitrepo2-$x > git-log-$x
325 test_cmp hg-log-hg hg-log-git &&
326 test_cmp git-log-hg git-log-git
329 test_expect_success 'file removal' '
330 mkdir -p tmp && cd tmp &&
331 test_when_finished "cd .. && rm -rf tmp" &&
334 git init -q gitrepo &&
336 echo alpha > alpha &&
338 git commit -m "add alpha" &&
341 git commit -m "add beta"
343 echo blah > foo/bar &&
345 git commit -m "add foo" &&
347 git commit -m "remove alpha" &&
349 git commit -m "remove foo/bar"
354 hg_clone_$x gitrepo hgrepo-$x &&
361 git_clone_$x hgrepo-$x gitrepo2-$x &&
362 git_log gitrepo2-$x > log-$x
365 test_cmp output-hg output-git &&
366 test_cmp log-hg log-git
369 test_expect_success 'git tags' '
370 mkdir -p tmp && cd tmp &&
371 test_when_finished "cd .. && rm -rf tmp" &&
374 git init -q gitrepo &&
376 git config receive.denyCurrentBranch ignore &&
377 echo alpha > alpha &&
379 git commit -m "add alpha" &&
384 git commit -m "add beta" &&
385 git tag -a -m "added tag beta" beta
389 hg_clone_$x gitrepo hgrepo-$x &&
390 hg_log hgrepo-$x > log-$x
393 test_cmp log-hg log-git
396 test_expect_success 'hg author' '
397 mkdir -p tmp && cd tmp &&
398 test_when_finished "cd .. && rm -rf tmp" &&
402 git init -q gitrepo-$x &&
405 echo alpha > alpha &&
407 git commit -m "add alpha" &&
408 git checkout -q -b not-master
412 hg_clone_$x gitrepo-$x hgrepo-$x &&
418 hg commit -u "test" -m "add beta" &&
420 echo gamma >> beta &&
421 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
423 echo gamma > gamma &&
425 hg commit -u "<test@example.com>" -m "add gamma" &&
427 echo delta > delta &&
429 hg commit -u "name<test@example.com>" -m "add delta" &&
431 echo epsilon > epsilon &&
433 hg commit -u "name <test@example.com" -m "add epsilon" &&
437 hg commit -u " test " -m "add zeta" &&
441 hg commit -u "test < test@example.com >" -m "add eta" &&
443 echo theta > theta &&
445 hg commit -u "test >test@example.com>" -m "add theta" &&
449 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
452 hg_push_$x hgrepo-$x gitrepo-$x &&
453 hg_clone_$x gitrepo-$x hgrepo2-$x &&
455 hg_log hgrepo2-$x > hg-log-$x &&
456 git_log gitrepo-$x > git-log-$x
459 test_cmp hg-log-hg hg-log-git &&
460 test_cmp git-log-hg git-log-git
463 test_expect_success 'hg branch' '
464 mkdir -p tmp && cd tmp &&
465 test_when_finished "cd .. && rm -rf tmp" &&
469 git init -q gitrepo-$x &&
472 echo alpha > alpha &&
474 git commit -q -m "add alpha" &&
475 git checkout -q -b not-master
479 hg_clone_$x gitrepo-$x hgrepo-$x &&
484 hg -q commit -m "rename alpha to beta" &&
485 hg branch gamma | grep -v "permanent and global" &&
486 hg -q commit -m "started branch gamma"
489 hg_push_$x hgrepo-$x gitrepo-$x &&
490 hg_clone_$x gitrepo-$x hgrepo2-$x &&
492 hg_log hgrepo2-$x > hg-log-$x &&
493 git_log gitrepo-$x > git-log-$x
496 test_cmp hg-log-hg hg-log-git &&
497 test_cmp git-log-hg git-log-git
500 test_expect_success 'hg tags' '
501 mkdir -p tmp && cd tmp &&
502 test_when_finished "cd .. && rm -rf tmp" &&
506 git init -q gitrepo-$x &&
509 echo alpha > alpha &&
511 git commit -m "add alpha" &&
512 git checkout -q -b not-master
516 hg_clone_$x gitrepo-$x hgrepo-$x &&
523 hg_push_$x hgrepo-$x gitrepo-$x &&
524 hg_clone_$x gitrepo-$x hgrepo2-$x &&
527 git --git-dir=gitrepo-$x/.git tag -l &&
529 cat hgrepo2-$x/.hgtags
533 test_cmp output-hg output-git