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 bidirectionality of remote-hg'
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'
25 hg
-R $1 bookmark
-f -r tip master
&&
26 git clone
-q "hg::$PWD/$1" $2
33 hg
-R $2 bookmark
-i master
&&
35 git push
-q "hg::$PWD/../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
38 (cd $2 && hg
-q update
)
45 old
=$
(git symbolic-ref
--short HEAD
)
46 git checkout
-q -b tmp
&&
47 git fetch
-q "hg::$PWD/../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
48 git checkout
-q $old &&
49 git branch
-q -D tmp
2> /dev
/null || true
54 hg
-R $1 log
--graph --debug |
grep -v 'tag: *default/'
60 echo "username = A U Thor <author@example.com>"
62 echo "backout = -d \"0 0\""
63 echo "commit = -d \"0 0\""
64 echo "debugrawcommit = -d \"0 0\""
65 echo "tag = -d \"0 0\""
67 git config
--global remote-hg.hg-git-compat true
69 export HGEDITOR
=/usr
/bin
/true
71 export GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
72 export GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
77 test_expect_success
'encoding' '
78 mkdir -p tmp && cd tmp &&
79 test_when_finished "cd .. && rm -rf tmp" &&
82 git init -q gitrepo &&
87 git commit -m "add älphà" &&
89 export GIT_AUTHOR_NAME="tést èncödîng" &&
92 git commit -m "add beta" &&
96 git commit -m "add gämmâ" &&
98 : TODO git config i18n.commitencoding latin-1 &&
101 git commit -m "add déltà"
104 hg_clone gitrepo hgrepo &&
105 git_clone hgrepo gitrepo2 &&
106 hg_clone gitrepo2 hgrepo2 &&
108 HGENCODING=utf-8 hg_log hgrepo > expected &&
109 HGENCODING=utf-8 hg_log hgrepo2 > actual &&
111 test_cmp expected actual
114 test_expect_success
'file removal' '
115 mkdir -p tmp && cd tmp &&
116 test_when_finished "cd .. && rm -rf tmp" &&
119 git init -q gitrepo &&
121 echo alpha > alpha &&
123 git commit -m "add alpha" &&
126 git commit -m "add beta"
128 echo blah > foo/bar &&
130 git commit -m "add foo" &&
132 git commit -m "remove alpha" &&
134 git commit -m "remove foo/bar"
137 hg_clone gitrepo hgrepo &&
138 git_clone hgrepo gitrepo2 &&
139 hg_clone gitrepo2 hgrepo2 &&
141 hg_log hgrepo > expected &&
142 hg_log hgrepo2 > actual &&
144 test_cmp expected actual
147 test_expect_success
'git tags' '
148 mkdir -p tmp && cd tmp &&
149 test_when_finished "cd .. && rm -rf tmp" &&
152 git init -q gitrepo &&
154 git config receive.denyCurrentBranch ignore &&
155 echo alpha > alpha &&
157 git commit -m "add alpha" &&
162 git commit -m "add beta" &&
163 git tag -a -m "added tag beta" beta
166 hg_clone gitrepo hgrepo &&
167 git_clone hgrepo gitrepo2 &&
168 hg_clone gitrepo2 hgrepo2 &&
170 hg_log hgrepo > expected &&
171 hg_log hgrepo2 > actual &&
173 test_cmp expected actual
176 test_expect_success
'hg branch' '
177 mkdir -p tmp && cd tmp &&
178 test_when_finished "cd .. && rm -rf tmp" &&
181 git init -q gitrepo &&
184 echo alpha > alpha &&
186 git commit -q -m "add alpha" &&
187 git checkout -q -b not-master
191 hg_clone gitrepo hgrepo &&
196 hg -q commit -m "rename alpha to beta" &&
197 hg branch gamma | grep -v "permanent and global" &&
198 hg -q commit -m "started branch gamma"
201 hg_push hgrepo gitrepo &&
202 hg_clone gitrepo hgrepo2 &&
204 : TODO, avoid "master" bookmark &&
205 (cd hgrepo2 && hg checkout gamma) &&
207 hg_log hgrepo > expected &&
208 hg_log hgrepo2 > actual &&
210 test_cmp expected actual
213 test_expect_success
'hg tags' '
214 mkdir -p tmp && cd tmp &&
215 test_when_finished "cd .. && rm -rf tmp" &&
218 git init -q gitrepo &&
221 echo alpha > alpha &&
223 git commit -m "add alpha" &&
224 git checkout -q -b not-master
228 hg_clone gitrepo hgrepo &&
235 hg_push hgrepo gitrepo &&
236 hg_clone gitrepo hgrepo2 &&
238 hg_log hgrepo > expected &&
239 hg_log hgrepo2 > actual &&
241 test_cmp expected actual