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 -n "$TEST_DIRECTORY" || TEST_DIRECTORY
=${0%/*}/..
/..
/t
12 .
"$TEST_DIRECTORY"/test-lib.sh
14 if ! test_have_prereq PYTHON
16 skip_all
='skipping remote-hg tests; python not available'
20 if ! python
-c 'import mercurial'
22 skip_all
='skipping remote-hg tests; mercurial not available'
26 if ! python
-c 'import hggit'
28 skip_all
='skipping remote-hg tests; hg-git not available'
32 # clone to a git repo with git
34 git clone
-q "hg::$1" $2 &&
35 (cd $2 && git checkout master
&& git branch
-D default
)
38 # clone to an hg repo with git
42 hg
-R $2 bookmark
-i master
&&
44 git push
-q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
47 (cd $2 && hg
-q update
)
50 # clone to a git repo with hg
55 hg bookmark
-i -f -r tip master
&&
56 hg
-q push
-r master ..
/$2 || true
60 # clone to an hg repo with hg
65 # push an hg repo with git
69 git checkout
-q -b tmp
&&
70 git fetch
-q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
71 git branch
-D default
&&
72 git checkout
-q @
{-1} &&
73 git branch
-q -D tmp
2>/dev
/null || true
77 # push an hg git repo with hg
81 hg
-q push ..
/$2 || true
86 hg
-R $1 log
--graph --debug >log
&&
87 grep -v 'tag: *default/' log
91 git
--git-dir=$1/.git fast-export
--branches
97 echo "username = A U Thor <author@example.com>"
99 echo "backout = -d \"0 0\""
100 echo "commit = -d \"0 0\""
101 echo "debugrawcommit = -d \"0 0\""
102 echo "tag = -d \"0 0\""
104 echo "hgext.bookmarks ="
108 git config
--global receive.denycurrentbranch warn
109 git config
--global remote-hg.hg-git-compat true
110 git config
--global remote-hg.track-branches false
115 GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
116 GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
117 export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
122 test_expect_success
'executable bit' '
123 test_when_finished "rm -rf gitrepo* hgrepo*" &&
126 git init -q gitrepo &&
131 git commit -m "add alpha" &&
134 git commit -m "set executable bit" &&
137 git commit -m "clear executable bit"
143 hg_clone_$x gitrepo hgrepo-$x &&
146 hg manifest -r 1 -v &&
150 git_clone_$x hgrepo-$x gitrepo2-$x &&
151 git_log gitrepo2-$x >"log-$x"
154 test_cmp output-hg output-git &&
155 test_cmp log-hg log-git
158 test_expect_success
'symlink' '
159 test_when_finished "rm -rf gitrepo* hgrepo*" &&
162 git init -q gitrepo &&
166 git commit -m "add alpha" &&
169 git commit -m "add beta"
175 hg_clone_$x gitrepo hgrepo-$x &&
181 git_clone_$x hgrepo-$x gitrepo2-$x &&
182 git_log gitrepo2-$x >"log-$x"
185 test_cmp output-hg output-git &&
186 test_cmp log-hg log-git
189 test_expect_success
'merge conflict 1' '
190 test_when_finished "rm -rf gitrepo* hgrepo*" &&
208 hg resolve -m afile &&
209 hg ci -m "merge to C"
214 git_clone_$x hgrepo1 gitrepo-$x &&
215 hg_clone_$x gitrepo-$x hgrepo2-$x &&
216 hg_log hgrepo2-$x >"hg-log-$x" &&
217 git_log gitrepo-$x >"git-log-$x"
220 test_cmp hg-log-hg hg-log-git &&
221 test_cmp git-log-hg git-log-git
224 test_expect_success
'merge conflict 2' '
225 test_when_finished "rm -rf gitrepo* hgrepo*" &&
241 hg merge -r1 || true &&
243 hg resolve -m afile &&
244 hg ci -m "merge to B"
249 git_clone_$x hgrepo1 gitrepo-$x &&
250 hg_clone_$x gitrepo-$x hgrepo2-$x &&
251 hg_log hgrepo2-$x >"hg-log-$x" &&
252 git_log gitrepo-$x >"git-log-$x"
255 test_cmp hg-log-hg hg-log-git &&
256 test_cmp git-log-hg git-log-git
259 test_expect_success
'converged merge' '
260 test_when_finished "rm -rf gitrepo* hgrepo*" &&
279 hg merge -r2 || true &&
285 git_clone_$x hgrepo1 gitrepo-$x &&
286 hg_clone_$x gitrepo-$x hgrepo2-$x &&
287 hg_log hgrepo2-$x >"hg-log-$x" &&
288 git_log gitrepo-$x >"git-log-$x"
291 test_cmp hg-log-hg hg-log-git &&
292 test_cmp git-log-hg git-log-git
295 test_expect_success
'encoding' '
296 test_when_finished "rm -rf gitrepo* hgrepo*" &&
299 git init -q gitrepo &&
304 git commit -m "add älphà" &&
306 GIT_AUTHOR_NAME="tést èncödîng" &&
307 export GIT_AUTHOR_NAME &&
310 git commit -m "add beta" &&
314 git commit -m "add gämmâ" &&
316 : TODO git config i18n.commitencoding latin-1 &&
319 git commit -m "add déltà"
324 hg_clone_$x gitrepo hgrepo-$x &&
325 git_clone_$x hgrepo-$x gitrepo2-$x &&
327 HGENCODING=utf-8 hg_log hgrepo-$x >"hg-log-$x" &&
328 git_log gitrepo2-$x >"git-log-$x"
331 test_cmp hg-log-hg hg-log-git &&
332 test_cmp git-log-hg git-log-git
335 test_expect_success
'file removal' '
336 test_when_finished "rm -rf gitrepo* hgrepo*" &&
339 git init -q gitrepo &&
343 git commit -m "add alpha" &&
346 git commit -m "add beta"
348 echo blah >foo/bar &&
350 git commit -m "add foo" &&
352 git commit -m "remove alpha" &&
354 git commit -m "remove foo/bar"
360 hg_clone_$x gitrepo hgrepo-$x &&
367 git_clone_$x hgrepo-$x gitrepo2-$x &&
368 git_log gitrepo2-$x >"log-$x"
371 test_cmp output-hg output-git &&
372 test_cmp log-hg log-git
375 test_expect_success
'git tags' '
376 test_when_finished "rm -rf gitrepo* hgrepo*" &&
379 git init -q gitrepo &&
381 git config receive.denyCurrentBranch ignore &&
384 git commit -m "add alpha" &&
389 git commit -m "add beta" &&
390 git tag -a -m "added tag beta" beta
395 hg_clone_$x gitrepo hgrepo-$x &&
396 hg_log hgrepo-$x >"log-$x"
399 test_cmp log-hg log-git
402 test_expect_success
'hg author' '
403 test_when_finished "rm -rf gitrepo* hgrepo*" &&
408 git init -q gitrepo-$x &&
413 git commit -m "add alpha" &&
414 git checkout -q -b not-master
418 hg_clone_$x gitrepo-$x hgrepo-$x &&
424 hg commit -u "test" -m "add beta" &&
427 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
431 hg commit -u "<test@example.com>" -m "add gamma" &&
435 hg commit -u "name<test@example.com>" -m "add delta" &&
437 echo epsilon >epsilon &&
439 hg commit -u "name <test@example.com" -m "add epsilon" &&
443 hg commit -u " test " -m "add zeta" &&
447 hg commit -u "test < test@example.com >" -m "add eta" &&
451 hg commit -u "test >test@example.com>" -m "add theta" &&
455 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
458 hg_push_$x hgrepo-$x gitrepo-$x &&
459 hg_clone_$x gitrepo-$x hgrepo2-$x &&
461 hg_log hgrepo2-$x >"hg-log-$x" &&
462 git_log gitrepo-$x >"git-log-$x"
465 test_cmp hg-log-hg hg-log-git &&
466 test_cmp git-log-hg git-log-git
469 test_expect_success
'hg branch' '
470 test_when_finished "rm -rf gitrepo* hgrepo*" &&
475 git init -q gitrepo-$x &&
480 git commit -q -m "add alpha" &&
481 git checkout -q -b not-master
485 hg_clone_$x gitrepo-$x hgrepo-$x &&
490 hg -q commit -m "rename alpha to beta" &&
491 hg branch gamma | grep -v "permanent and global" &&
492 hg -q commit -m "started branch gamma"
495 hg_push_$x hgrepo-$x gitrepo-$x &&
496 hg_clone_$x gitrepo-$x hgrepo2-$x &&
498 hg_log hgrepo2-$x >"hg-log-$x" &&
499 git_log gitrepo-$x >"git-log-$x"
502 test_cmp hg-log-hg hg-log-git &&
503 test_cmp git-log-hg git-log-git
506 test_expect_success
'hg tags' '
507 test_when_finished "rm -rf gitrepo* hgrepo*" &&
512 git init -q gitrepo-$x &&
517 git commit -m "add alpha" &&
518 git checkout -q -b not-master
522 hg_clone_$x gitrepo-$x hgrepo-$x &&
529 hg_push_$x hgrepo-$x gitrepo-$x &&
530 hg_clone_$x gitrepo-$x hgrepo2-$x &&
533 git --git-dir=gitrepo-$x/.git tag -l &&
535 cat hgrepo2-$x/.hgtags
539 test_cmp output-hg output-git