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
106 HGEDITOR
=/usr
/bin
/true
108 GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
109 GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
110 export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
115 test_expect_success
'executable bit' '
116 mkdir -p tmp && cd tmp &&
117 test_when_finished "cd .. && rm -rf tmp" &&
120 git init -q gitrepo &&
122 echo alpha > alpha &&
125 git commit -m "add alpha" &&
128 git commit -m "set executable bit" &&
131 git commit -m "clear executable bit"
136 hg_clone_$x gitrepo hgrepo-$x &&
139 hg manifest -r 1 -v &&
143 git_clone_$x hgrepo-$x gitrepo2-$x &&
144 git_log gitrepo2-$x > log-$x
147 test_cmp output-hg output-git &&
148 test_cmp log-hg log-git
151 test_expect_success
'symlink' '
152 mkdir -p tmp && cd tmp &&
153 test_when_finished "cd .. && rm -rf tmp" &&
156 git init -q gitrepo &&
158 echo alpha > alpha &&
160 git commit -m "add alpha" &&
163 git commit -m "add beta"
168 hg_clone_$x gitrepo hgrepo-$x &&
174 git_clone_$x hgrepo-$x gitrepo2-$x &&
175 git_log gitrepo2-$x > log-$x
178 test_cmp output-hg output-git &&
179 test_cmp log-hg log-git
182 test_expect_success
'merge conflict 1' '
183 mkdir -p tmp && cd tmp &&
184 test_when_finished "cd .. && rm -rf tmp" &&
200 hg merge -r1 || true &&
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 mkdir -p tmp && cd tmp &&
219 test_when_finished "cd .. && rm -rf tmp" &&
235 hg merge -r1 || true &&
237 hg resolve -m afile &&
238 hg ci -m "merge to B"
242 git_clone_$x hgrepo1 gitrepo-$x &&
243 hg_clone_$x gitrepo-$x hgrepo2-$x &&
244 hg_log hgrepo2-$x > hg-log-$x &&
245 git_log gitrepo-$x > git-log-$x
248 test_cmp hg-log-hg hg-log-git &&
249 test_cmp git-log-hg git-log-git
252 test_expect_success
'converged merge' '
253 mkdir -p tmp && cd tmp &&
254 test_when_finished "cd .. && rm -rf tmp" &&
273 hg merge -r2 || true &&
278 git_clone_$x hgrepo1 gitrepo-$x &&
279 hg_clone_$x gitrepo-$x hgrepo2-$x &&
280 hg_log hgrepo2-$x > hg-log-$x &&
281 git_log gitrepo-$x > git-log-$x
284 test_cmp hg-log-hg hg-log-git &&
285 test_cmp git-log-hg git-log-git
288 test_expect_success
'encoding' '
289 mkdir -p tmp && cd tmp &&
290 test_when_finished "cd .. && rm -rf tmp" &&
293 git init -q gitrepo &&
296 echo alpha > alpha &&
298 git commit -m "add älphà" &&
300 GIT_AUTHOR_NAME="tést èncödîng" &&
301 export GIT_AUTHOR_NAME &&
304 git commit -m "add beta" &&
306 echo gamma > gamma &&
308 git commit -m "add gämmâ" &&
310 : TODO git config i18n.commitencoding latin-1 &&
311 echo delta > delta &&
313 git commit -m "add déltà"
317 hg_clone_$x gitrepo hgrepo-$x &&
318 git_clone_$x hgrepo-$x gitrepo2-$x &&
320 HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
321 git_log gitrepo2-$x > git-log-$x
324 test_cmp hg-log-hg hg-log-git &&
325 test_cmp git-log-hg git-log-git
328 test_expect_success
'file removal' '
329 mkdir -p tmp && cd tmp &&
330 test_when_finished "cd .. && rm -rf tmp" &&
333 git init -q gitrepo &&
335 echo alpha > alpha &&
337 git commit -m "add alpha" &&
340 git commit -m "add beta"
342 echo blah > foo/bar &&
344 git commit -m "add foo" &&
346 git commit -m "remove alpha" &&
348 git commit -m "remove foo/bar"
353 hg_clone_$x gitrepo hgrepo-$x &&
360 git_clone_$x hgrepo-$x gitrepo2-$x &&
361 git_log gitrepo2-$x > log-$x
364 test_cmp output-hg output-git &&
365 test_cmp log-hg log-git
368 test_expect_success
'git tags' '
369 mkdir -p tmp && cd tmp &&
370 test_when_finished "cd .. && rm -rf tmp" &&
373 git init -q gitrepo &&
375 git config receive.denyCurrentBranch ignore &&
376 echo alpha > alpha &&
378 git commit -m "add alpha" &&
383 git commit -m "add beta" &&
384 git tag -a -m "added tag beta" beta
388 hg_clone_$x gitrepo hgrepo-$x &&
389 hg_log hgrepo-$x > log-$x
392 test_cmp log-hg log-git
395 test_expect_success
'hg author' '
396 mkdir -p tmp && cd tmp &&
397 test_when_finished "cd .. && rm -rf tmp" &&
401 git init -q gitrepo-$x &&
404 echo alpha > alpha &&
406 git commit -m "add alpha" &&
407 git checkout -q -b not-master
411 hg_clone_$x gitrepo-$x hgrepo-$x &&
417 hg commit -u "test" -m "add beta" &&
419 echo gamma >> beta &&
420 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
422 echo gamma > gamma &&
424 hg commit -u "<test@example.com>" -m "add gamma" &&
426 echo delta > delta &&
428 hg commit -u "name<test@example.com>" -m "add delta" &&
430 echo epsilon > epsilon &&
432 hg commit -u "name <test@example.com" -m "add epsilon" &&
436 hg commit -u " test " -m "add zeta" &&
440 hg commit -u "test < test@example.com >" -m "add eta" &&
442 echo theta > theta &&
444 hg commit -u "test >test@example.com>" -m "add theta" &&
448 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
451 hg_push_$x hgrepo-$x gitrepo-$x &&
452 hg_clone_$x gitrepo-$x hgrepo2-$x &&
454 hg_log hgrepo2-$x > hg-log-$x &&
455 git_log gitrepo-$x > git-log-$x
458 test_cmp git-log-hg git-log-git &&
460 test_cmp hg-log-hg hg-log-git &&
461 test_cmp git-log-hg git-log-git
464 test_expect_success
'hg branch' '
465 mkdir -p tmp && cd tmp &&
466 test_when_finished "cd .. && rm -rf tmp" &&
470 git init -q gitrepo-$x &&
473 echo alpha > alpha &&
475 git commit -q -m "add alpha" &&
476 git checkout -q -b not-master
480 hg_clone_$x gitrepo-$x hgrepo-$x &&
485 hg -q commit -m "rename alpha to beta" &&
486 hg branch gamma | grep -v "permanent and global" &&
487 hg -q commit -m "started branch gamma"
490 hg_push_$x hgrepo-$x gitrepo-$x &&
491 hg_clone_$x gitrepo-$x hgrepo2-$x &&
493 hg_log hgrepo2-$x > hg-log-$x &&
494 git_log gitrepo-$x > git-log-$x
497 test_cmp hg-log-hg hg-log-git &&
498 test_cmp git-log-hg git-log-git
501 test_expect_success
'hg tags' '
502 mkdir -p tmp && cd tmp &&
503 test_when_finished "cd .. && rm -rf tmp" &&
507 git init -q gitrepo-$x &&
510 echo alpha > alpha &&
512 git commit -m "add alpha" &&
513 git checkout -q -b not-master
517 hg_clone_$x gitrepo-$x hgrepo-$x &&
524 hg_push_$x hgrepo-$x gitrepo-$x &&
525 hg_clone_$x gitrepo-$x hgrepo2-$x &&
528 git --git-dir=gitrepo-$x/.git tag -l &&
530 cat hgrepo2-$x/.hgtags
534 test_cmp output-hg output-git