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
-c 'import mercurial'; then
19 skip_all
='skipping remote-hg tests; mercurial not available'
23 if ! python
-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::$1" $2
33 # clone to an hg repo with git
37 hg
-R $2 bookmark
-i master
&&
39 git push
-q "hg::../$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 git checkout
-q -b tmp
&&
65 git fetch
-q "hg::../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
66 git checkout
-q @
{-1} &&
67 git branch
-q -D tmp
2> /dev
/null || true
71 # push an hg git repo with hg
75 hg
-q push ..
/$2 || true
80 hg
-R $1 log
--graph --debug >log
&&
81 grep -v 'tag: *default/' log
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 ="
101 ) >> "$HOME"/.hgrc
&&
102 git config
--global receive.denycurrentbranch warn
103 git config
--global remote-hg.hg-git-compat true
104 git config
--global remote-hg.track-branches false
109 GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
110 GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
111 export HGEDITOR HGMERGE GIT_AUTHOR_DATE GIT_COMMITTER_DATE
116 test_expect_success
'executable bit' '
117 test_when_finished "rm -rf gitrepo* hgrepo*" &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
155 git init -q gitrepo &&
157 echo alpha > alpha &&
159 git commit -m "add alpha" &&
162 git commit -m "add beta"
167 hg_clone_$x gitrepo hgrepo-$x &&
173 git_clone_$x hgrepo-$x gitrepo2-$x &&
174 git_log gitrepo2-$x > log-$x
177 test_cmp output-hg output-git &&
178 test_cmp log-hg log-git
181 test_expect_success
'merge conflict 1' '
182 test_when_finished "rm -rf gitrepo* hgrepo*" &&
200 hg resolve -m afile &&
201 hg ci -m "merge to C"
205 git_clone_$x hgrepo1 gitrepo-$x &&
206 hg_clone_$x gitrepo-$x hgrepo2-$x &&
207 hg_log hgrepo2-$x > hg-log-$x &&
208 git_log gitrepo-$x > git-log-$x
211 test_cmp hg-log-hg hg-log-git &&
212 test_cmp git-log-hg git-log-git
215 test_expect_success
'merge conflict 2' '
216 test_when_finished "rm -rf gitrepo* hgrepo*" &&
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 test_when_finished "rm -rf gitrepo* hgrepo*" &&
269 hg merge -r2 || true &&
274 git_clone_$x hgrepo1 gitrepo-$x &&
275 hg_clone_$x gitrepo-$x hgrepo2-$x &&
276 hg_log hgrepo2-$x > hg-log-$x &&
277 git_log gitrepo-$x > git-log-$x
280 test_cmp hg-log-hg hg-log-git &&
281 test_cmp git-log-hg git-log-git
284 test_expect_success
'encoding' '
285 test_when_finished "rm -rf gitrepo* hgrepo*" &&
288 git init -q gitrepo &&
291 echo alpha > alpha &&
293 git commit -m "add älphà" &&
295 GIT_AUTHOR_NAME="tést èncödîng" &&
296 export GIT_AUTHOR_NAME &&
299 git commit -m "add beta" &&
301 echo gamma > gamma &&
303 git commit -m "add gämmâ" &&
305 : TODO git config i18n.commitencoding latin-1 &&
306 echo delta > delta &&
308 git commit -m "add déltà"
312 hg_clone_$x gitrepo hgrepo-$x &&
313 git_clone_$x hgrepo-$x gitrepo2-$x &&
315 HGENCODING=utf-8 hg_log hgrepo-$x > hg-log-$x &&
316 git_log gitrepo2-$x > git-log-$x
319 test_cmp hg-log-hg hg-log-git &&
320 test_cmp git-log-hg git-log-git
323 test_expect_success
'file removal' '
324 test_when_finished "rm -rf gitrepo* hgrepo*" &&
327 git init -q gitrepo &&
329 echo alpha > alpha &&
331 git commit -m "add alpha" &&
334 git commit -m "add beta"
336 echo blah > foo/bar &&
338 git commit -m "add foo" &&
340 git commit -m "remove alpha" &&
342 git commit -m "remove foo/bar"
347 hg_clone_$x gitrepo hgrepo-$x &&
354 git_clone_$x hgrepo-$x gitrepo2-$x &&
355 git_log gitrepo2-$x > log-$x
358 test_cmp output-hg output-git &&
359 test_cmp log-hg log-git
362 test_expect_success
'git tags' '
363 test_when_finished "rm -rf gitrepo* hgrepo*" &&
366 git init -q gitrepo &&
368 git config receive.denyCurrentBranch ignore &&
369 echo alpha > alpha &&
371 git commit -m "add alpha" &&
376 git commit -m "add beta" &&
377 git tag -a -m "added tag beta" beta
381 hg_clone_$x gitrepo hgrepo-$x &&
382 hg_log hgrepo-$x > log-$x
385 test_cmp log-hg log-git
388 test_expect_success
'hg author' '
389 test_when_finished "rm -rf gitrepo* hgrepo*" &&
393 git init -q gitrepo-$x &&
396 echo alpha > alpha &&
398 git commit -m "add alpha" &&
399 git checkout -q -b not-master
403 hg_clone_$x gitrepo-$x hgrepo-$x &&
409 hg commit -u "test" -m "add beta" &&
411 echo gamma >> beta &&
412 hg commit -u "test <test@example.com> (comment)" -m "modify beta" &&
414 echo gamma > gamma &&
416 hg commit -u "<test@example.com>" -m "add gamma" &&
418 echo delta > delta &&
420 hg commit -u "name<test@example.com>" -m "add delta" &&
422 echo epsilon > epsilon &&
424 hg commit -u "name <test@example.com" -m "add epsilon" &&
428 hg commit -u " test " -m "add zeta" &&
432 hg commit -u "test < test@example.com >" -m "add eta" &&
434 echo theta > theta &&
436 hg commit -u "test >test@example.com>" -m "add theta" &&
440 hg commit -u "test <test <at> example <dot> com>" -m "add iota"
443 hg_push_$x hgrepo-$x gitrepo-$x &&
444 hg_clone_$x gitrepo-$x hgrepo2-$x &&
446 hg_log hgrepo2-$x > hg-log-$x &&
447 git_log gitrepo-$x > git-log-$x
450 test_cmp hg-log-hg hg-log-git &&
451 test_cmp git-log-hg git-log-git
454 test_expect_success
'hg branch' '
455 test_when_finished "rm -rf gitrepo* hgrepo*" &&
459 git init -q gitrepo-$x &&
462 echo alpha > alpha &&
464 git commit -q -m "add alpha" &&
465 git checkout -q -b not-master
469 hg_clone_$x gitrepo-$x hgrepo-$x &&
474 hg -q commit -m "rename alpha to beta" &&
475 hg branch gamma | grep -v "permanent and global" &&
476 hg -q commit -m "started branch gamma"
479 hg_push_$x hgrepo-$x gitrepo-$x &&
480 hg_clone_$x gitrepo-$x hgrepo2-$x &&
482 hg_log hgrepo2-$x > hg-log-$x &&
483 git_log gitrepo-$x > git-log-$x
486 test_cmp hg-log-hg hg-log-git &&
487 test_cmp git-log-hg git-log-git
490 test_expect_success
'hg tags' '
491 test_when_finished "rm -rf gitrepo* hgrepo*" &&
495 git init -q gitrepo-$x &&
498 echo alpha > alpha &&
500 git commit -m "add alpha" &&
501 git checkout -q -b not-master
505 hg_clone_$x gitrepo-$x hgrepo-$x &&
512 hg_push_$x hgrepo-$x gitrepo-$x &&
513 hg_clone_$x gitrepo-$x hgrepo2-$x &&
516 git --git-dir=gitrepo-$x/.git tag -l &&
518 cat hgrepo2-$x/.hgtags
522 test_cmp output-hg output-git