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
144 test_cmp output-hg output-git &&
145 test_cmp log-hg log-git
148 test_expect_success
'symlink' '
149 mkdir -p tmp && cd tmp &&
150 test_when_finished "cd .. && rm -rf tmp" &&
153 git init -q gitrepo &&
155 echo alpha > alpha &&
157 git commit -m "add alpha" &&
160 git commit -m "add beta"
165 hg_clone_$x gitrepo hgrepo-$x &&
171 git_clone_$x hgrepo-$x gitrepo2-$x &&
172 git_log gitrepo2-$x > log-$x
175 test_cmp output-hg output-git &&
176 test_cmp log-hg log-git
179 test_expect_success
'merge conflict 1' '
180 mkdir -p tmp && cd tmp &&
181 test_when_finished "cd .. && rm -rf tmp" &&
197 hg merge -r1 || true &&
199 hg resolve -m afile &&
200 hg ci -m "merge to C"
204 git_clone_$x hgrepo1 gitrepo-$x &&
205 hg_clone_$x gitrepo-$x hgrepo2-$x &&
206 hg_log hgrepo2-$x > hg-log-$x &&
207 git_log gitrepo-$x > git-log-$x
210 test_cmp hg-log-hg hg-log-git &&
211 test_cmp git-log-hg git-log-git
214 test_expect_success
'merge conflict 2' '
215 mkdir -p tmp && cd tmp &&
216 test_when_finished "cd .. && rm -rf tmp" &&
232 hg merge -r1 || true &&
234 hg resolve -m afile &&
235 hg ci -m "merge to B"
239 git_clone_$x hgrepo1 gitrepo-$x &&
240 hg_clone_$x gitrepo-$x hgrepo2-$x &&
241 hg_log hgrepo2-$x > hg-log-$x &&
242 git_log gitrepo-$x > git-log-$x
245 test_cmp hg-log-hg hg-log-git &&
246 test_cmp git-log-hg git-log-git
249 test_expect_success
'converged merge' '
250 mkdir -p tmp && cd tmp &&
251 test_when_finished "cd .. && rm -rf tmp" &&
270 hg merge -r2 || true &&
275 git_clone_$x hgrepo1 gitrepo-$x &&
276 hg_clone_$x gitrepo-$x hgrepo2-$x &&
277 hg_log hgrepo2-$x > hg-log-$x &&
278 git_log gitrepo-$x > git-log-$x
281 test_cmp hg-log-hg hg-log-git &&
282 test_cmp git-log-hg git-log-git
285 test_expect_success
'encoding' '
286 mkdir -p tmp && cd tmp &&
287 test_when_finished "cd .. && rm -rf tmp" &&
290 git init -q gitrepo &&
293 echo alpha > alpha &&
295 git commit -m "add älphà" &&
297 export GIT_AUTHOR_NAME="tést èncödîng" &&
300 git commit -m "add beta" &&
302 echo gamma > gamma &&
304 git commit -m "add gämmâ" &&
306 : TODO git config i18n.commitencoding latin-1 &&
307 echo delta > delta &&
309 git commit -m "add déltà"
313 hg_clone_$x gitrepo hgrepo-$x &&
314 git_clone_$x hgrepo-$x gitrepo2-$x &&
316 HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
317 git_log gitrepo2-$x > git-log-$x
320 test_cmp hg-log-hg hg-log-git &&
321 test_cmp git-log-hg git-log-git
324 test_expect_success
'file removal' '
325 mkdir -p tmp && cd tmp &&
326 test_when_finished "cd .. && rm -rf tmp" &&
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 mkdir -p tmp && cd tmp &&
366 test_when_finished "cd .. && rm -rf tmp" &&
369 git init -q gitrepo &&
371 git config receive.denyCurrentBranch ignore &&
372 echo alpha > alpha &&
374 git commit -m "add alpha" &&
379 git commit -m "add beta" &&
380 git tag -a -m "added tag beta" beta
384 hg_clone_$x gitrepo hgrepo-$x &&
385 hg_log hgrepo-$x > log-$x
388 test_cmp log-hg log-git
391 test_expect_success
'hg author' '
392 mkdir -p tmp && cd tmp &&
393 test_when_finished "cd .. && rm -rf tmp" &&
397 git init -q gitrepo-$x &&
400 echo alpha > alpha &&
402 git commit -m "add alpha" &&
403 git checkout -q -b not-master
407 hg_clone_$x gitrepo-$x hgrepo-$x &&
413 hg commit -u "test" -m "add beta" &&
415 echo gamma >> beta &&
416 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
418 echo gamma > gamma &&
420 hg commit -u "<test@example.com>" -m "add gamma" &&
422 echo delta > delta &&
424 hg commit -u "name<test@example.com>" -m "add delta" &&
426 echo epsilon > epsilon &&
428 hg commit -u "name <test@example.com" -m "add epsilon" &&
432 hg commit -u " test " -m "add zeta" &&
436 hg commit -u "test < test@example.com >" -m "add eta" &&
438 echo theta > theta &&
440 hg commit -u "test >test@example.com>" -m "add theta" &&
444 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
447 hg_push_$x hgrepo-$x gitrepo-$x &&
448 hg_clone_$x gitrepo-$x hgrepo2-$x &&
450 hg_log hgrepo2-$x > hg-log-$x &&
451 git_log gitrepo-$x > git-log-$x
454 test_cmp git-log-hg git-log-git &&
456 test_cmp hg-log-hg hg-log-git &&
457 test_cmp git-log-hg git-log-git
460 test_expect_success
'hg branch' '
461 mkdir -p tmp && cd tmp &&
462 test_when_finished "cd .. && rm -rf tmp" &&
466 git init -q gitrepo-$x &&
469 echo alpha > alpha &&
471 git commit -q -m "add alpha" &&
472 git checkout -q -b not-master
476 hg_clone_$x gitrepo-$x hgrepo-$x &&
481 hg -q commit -m "rename alpha to beta" &&
482 hg branch gamma | grep -v "permanent and global" &&
483 hg -q commit -m "started branch gamma"
486 hg_push_$x hgrepo-$x gitrepo-$x &&
487 hg_clone_$x gitrepo-$x hgrepo2-$x &&
489 hg_log hgrepo2-$x > hg-log-$x &&
490 git_log gitrepo-$x > git-log-$x
493 test_cmp hg-log-hg hg-log-git &&
494 test_cmp git-log-hg git-log-git
497 test_expect_success
'hg tags' '
498 mkdir -p tmp && cd tmp &&
499 test_when_finished "cd .. && rm -rf tmp" &&
503 git init -q gitrepo-$x &&
506 echo alpha > alpha &&
508 git commit -m "add alpha" &&
509 git checkout -q -b not-master
513 hg_clone_$x gitrepo-$x hgrepo-$x &&
520 hg_push_$x hgrepo-$x gitrepo-$x &&
521 hg_clone_$x gitrepo-$x hgrepo2-$x &&
524 git --git-dir=gitrepo-$x/.git tag -l &&
526 cat hgrepo2-$x/.hgtags
530 test_cmp output-hg output-git