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
15 skip_all='skipping remote-hg tests; python not available'
19 if ! python -c 'import mercurial'
21 skip_all='skipping remote-hg tests; mercurial not available'
25 if ! python -c 'import hggit'
27 skip_all='skipping remote-hg tests; hg-git not available'
31 # clone to a git repo with git
33 git clone -q "hg::$1" $2 &&
34 (cd $2 && git checkout master && git branch -D default)
37 # clone to an hg repo with git
41 hg -R $2 bookmark -i master &&
43 git push -q "hg::../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
46 (cd $2 && hg -q update)
49 # clone to a git repo with hg
54 hg bookmark -i -f -r tip master &&
55 hg -q push -r master ../$2 || true
59 # clone to an hg repo with hg
64 # push an hg repo with git
68 git checkout -q -b tmp &&
69 git fetch -q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
70 git branch -D default &&
71 git checkout -q @{-1} &&
72 git branch -q -D tmp 2>/dev/null || true
76 # push an hg git repo with hg
80 hg -q push ../$2 || true
85 hg -R $1 log --graph --debug >log &&
86 grep -v 'tag: *default/' log
90 git --git-dir=$1/.git fast-export --branches
96 echo "username = A U Thor <author@example.com>"
98 echo "backout = -d \"0 0\""
99 echo "commit = -d \"0 0\""
100 echo "debugrawcommit = -d \"0 0\""
101 echo "tag = -d \"0 0\""
103 echo "hgext.bookmarks ="
107 git config --global receive.denycurrentbranch warn
108 git config --global remote-hg.hg-git-compat true
109 git config --global remote-hg.track-branches false
114 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230"
115 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
116 export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
121 test_expect_success 'executable bit' '
122 test_when_finished "rm -rf gitrepo* hgrepo*" &&
125 git init -q gitrepo &&
130 git commit -m "add alpha" &&
133 git commit -m "set executable bit" &&
136 git commit -m "clear executable bit"
142 hg_clone_$x gitrepo hgrepo-$x &&
145 hg manifest -r 1 -v &&
149 git_clone_$x hgrepo-$x gitrepo2-$x &&
150 git_log gitrepo2-$x >"log-$x"
153 test_cmp output-hg output-git &&
154 test_cmp log-hg log-git
157 test_expect_success 'symlink' '
158 test_when_finished "rm -rf gitrepo* hgrepo*" &&
161 git init -q gitrepo &&
165 git commit -m "add alpha" &&
168 git commit -m "add beta"
174 hg_clone_$x gitrepo hgrepo-$x &&
180 git_clone_$x hgrepo-$x gitrepo2-$x &&
181 git_log gitrepo2-$x >"log-$x"
184 test_cmp output-hg output-git &&
185 test_cmp log-hg log-git
188 test_expect_success 'merge conflict 1' '
189 test_when_finished "rm -rf gitrepo* hgrepo*" &&
207 hg resolve -m afile &&
208 hg ci -m "merge to C"
213 git_clone_$x hgrepo1 gitrepo-$x &&
214 hg_clone_$x gitrepo-$x hgrepo2-$x &&
215 hg_log hgrepo2-$x >"hg-log-$x" &&
216 git_log gitrepo-$x >"git-log-$x"
219 test_cmp hg-log-hg hg-log-git &&
220 test_cmp git-log-hg git-log-git
223 test_expect_success 'merge conflict 2' '
224 test_when_finished "rm -rf gitrepo* hgrepo*" &&
240 hg merge -r1 || true &&
242 hg resolve -m afile &&
243 hg ci -m "merge to B"
248 git_clone_$x hgrepo1 gitrepo-$x &&
249 hg_clone_$x gitrepo-$x hgrepo2-$x &&
250 hg_log hgrepo2-$x >"hg-log-$x" &&
251 git_log gitrepo-$x >"git-log-$x"
254 test_cmp hg-log-hg hg-log-git &&
255 test_cmp git-log-hg git-log-git
258 test_expect_success 'converged merge' '
259 test_when_finished "rm -rf gitrepo* hgrepo*" &&
278 hg merge -r2 || true &&
284 git_clone_$x hgrepo1 gitrepo-$x &&
285 hg_clone_$x gitrepo-$x hgrepo2-$x &&
286 hg_log hgrepo2-$x >"hg-log-$x" &&
287 git_log gitrepo-$x >"git-log-$x"
290 test_cmp hg-log-hg hg-log-git &&
291 test_cmp git-log-hg git-log-git
294 test_expect_success 'encoding' '
295 test_when_finished "rm -rf gitrepo* hgrepo*" &&
298 git init -q gitrepo &&
303 git commit -m "add älphà" &&
305 GIT_AUTHOR_NAME="tést èncödîng" &&
306 export GIT_AUTHOR_NAME &&
309 git commit -m "add beta" &&
313 git commit -m "add gämmâ" &&
315 : TODO git config i18n.commitencoding latin-1 &&
318 git commit -m "add déltà"
323 hg_clone_$x gitrepo hgrepo-$x &&
324 git_clone_$x hgrepo-$x gitrepo2-$x &&
326 HGENCODING=utf-8 hg_log hgrepo-$x >"hg-log-$x" &&
327 git_log gitrepo2-$x >"git-log-$x"
330 test_cmp hg-log-hg hg-log-git &&
331 test_cmp git-log-hg git-log-git
334 test_expect_success 'file removal' '
335 test_when_finished "rm -rf gitrepo* hgrepo*" &&
338 git init -q gitrepo &&
342 git commit -m "add alpha" &&
345 git commit -m "add beta"
347 echo blah >foo/bar &&
349 git commit -m "add foo" &&
351 git commit -m "remove alpha" &&
353 git commit -m "remove foo/bar"
359 hg_clone_$x gitrepo hgrepo-$x &&
366 git_clone_$x hgrepo-$x gitrepo2-$x &&
367 git_log gitrepo2-$x >"log-$x"
370 test_cmp output-hg output-git &&
371 test_cmp log-hg log-git
374 test_expect_success 'git tags' '
375 test_when_finished "rm -rf gitrepo* hgrepo*" &&
378 git init -q gitrepo &&
380 git config receive.denyCurrentBranch ignore &&
383 git commit -m "add alpha" &&
388 git commit -m "add beta" &&
389 git tag -a -m "added tag beta" beta
394 hg_clone_$x gitrepo hgrepo-$x &&
395 hg_log hgrepo-$x >"log-$x"
398 test_cmp log-hg log-git
401 test_expect_success 'hg author' '
402 test_when_finished "rm -rf gitrepo* hgrepo*" &&
407 git init -q gitrepo-$x &&
412 git commit -m "add alpha" &&
413 git checkout -q -b not-master
417 hg_clone_$x gitrepo-$x hgrepo-$x &&
423 hg commit -u "test" -m "add beta" &&
426 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
430 hg commit -u "<test@example.com>" -m "add gamma" &&
434 hg commit -u "name<test@example.com>" -m "add delta" &&
436 echo epsilon >epsilon &&
438 hg commit -u "name <test@example.com" -m "add epsilon" &&
442 hg commit -u " test " -m "add zeta" &&
446 hg commit -u "test < test@example.com >" -m "add eta" &&
450 hg commit -u "test >test@example.com>" -m "add theta" &&
454 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
457 hg_push_$x hgrepo-$x gitrepo-$x &&
458 hg_clone_$x gitrepo-$x hgrepo2-$x &&
460 hg_log hgrepo2-$x >"hg-log-$x" &&
461 git_log gitrepo-$x >"git-log-$x"
464 test_cmp hg-log-hg hg-log-git &&
465 test_cmp git-log-hg git-log-git
468 test_expect_success 'hg branch' '
469 test_when_finished "rm -rf gitrepo* hgrepo*" &&
474 git init -q gitrepo-$x &&
479 git commit -q -m "add alpha" &&
480 git checkout -q -b not-master
484 hg_clone_$x gitrepo-$x hgrepo-$x &&
489 hg -q commit -m "rename alpha to beta" &&
490 hg branch gamma | grep -v "permanent and global" &&
491 hg -q commit -m "started branch gamma"
494 hg_push_$x hgrepo-$x gitrepo-$x &&
495 hg_clone_$x gitrepo-$x hgrepo2-$x &&
497 hg_log hgrepo2-$x >"hg-log-$x" &&
498 git_log gitrepo-$x >"git-log-$x"
501 test_cmp hg-log-hg hg-log-git &&
502 test_cmp git-log-hg git-log-git
505 test_expect_success 'hg tags' '
506 test_when_finished "rm -rf gitrepo* hgrepo*" &&
511 git init -q gitrepo-$x &&
516 git commit -m "add alpha" &&
517 git checkout -q -b not-master
521 hg_clone_$x gitrepo-$x hgrepo-$x &&
528 hg_push_$x hgrepo-$x gitrepo-$x &&
529 hg_clone_$x gitrepo-$x hgrepo2-$x &&
532 git --git-dir=gitrepo-$x/.git tag -l &&
534 cat hgrepo2-$x/.hgtags
538 test_cmp output-hg output-git