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 git clone
-q "hg::$PWD/$1" $2
32 hg
-R $2 bookmark
-i master
&&
34 git push
-q "hg::$PWD/../$2" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*'
37 (cd $2 && hg
-q update
)
44 old
=$
(git symbolic-ref
--short HEAD
)
45 git checkout
-q -b tmp
&&
46 git fetch
-q "hg::$PWD/../$1" 'refs/tags/*:refs/tags/*' 'refs/heads/*:refs/heads/*' &&
47 git checkout
-q $old &&
48 git branch
-q -D tmp
2> /dev
/null || true
53 hg
-R $1 log
--graph --debug >log
&&
54 grep -v 'tag: *default/' log
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\""
69 git config
--global remote-hg.hg-git-compat true
71 HGEDITOR
=/usr
/bin
/true
72 GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230"
73 GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE"
74 export HGEDITOR GIT_AUTHOR_DATE GIT_COMMITTER_DATE
79 test_expect_success
'encoding' '
80 mkdir -p tmp && cd tmp &&
81 test_when_finished "cd .. && rm -rf tmp" &&
84 git init -q gitrepo &&
89 git commit -m "add älphà" &&
91 GIT_AUTHOR_NAME="tést èncödîng" &&
92 export GIT_AUTHOR_NAME &&
95 git commit -m "add beta" &&
99 git commit -m "add gämmâ" &&
101 : TODO git config i18n.commitencoding latin-1 &&
102 echo delta > delta &&
104 git commit -m "add déltà"
107 hg_clone gitrepo hgrepo &&
108 git_clone hgrepo gitrepo2 &&
109 hg_clone gitrepo2 hgrepo2 &&
111 HGENCODING=utf-8 hg_log hgrepo > expected &&
112 HGENCODING=utf-8 hg_log hgrepo2 > actual &&
114 test_cmp expected actual
117 test_expect_success
'file removal' '
118 mkdir -p tmp && cd tmp &&
119 test_when_finished "cd .. && rm -rf tmp" &&
122 git init -q gitrepo &&
124 echo alpha > alpha &&
126 git commit -m "add alpha" &&
129 git commit -m "add beta"
131 echo blah > foo/bar &&
133 git commit -m "add foo" &&
135 git commit -m "remove alpha" &&
137 git commit -m "remove foo/bar"
140 hg_clone gitrepo hgrepo &&
141 git_clone hgrepo gitrepo2 &&
142 hg_clone gitrepo2 hgrepo2 &&
144 hg_log hgrepo > expected &&
145 hg_log hgrepo2 > actual &&
147 test_cmp expected actual
150 test_expect_success
'git tags' '
151 mkdir -p tmp && cd tmp &&
152 test_when_finished "cd .. && rm -rf tmp" &&
155 git init -q gitrepo &&
157 git config receive.denyCurrentBranch ignore &&
158 echo alpha > alpha &&
160 git commit -m "add alpha" &&
165 git commit -m "add beta" &&
166 git tag -a -m "added tag beta" beta
169 hg_clone gitrepo hgrepo &&
170 git_clone hgrepo gitrepo2 &&
171 hg_clone gitrepo2 hgrepo2 &&
173 hg_log hgrepo > expected &&
174 hg_log hgrepo2 > actual &&
176 test_cmp expected actual
179 test_expect_success
'hg branch' '
180 mkdir -p tmp && cd tmp &&
181 test_when_finished "cd .. && rm -rf tmp" &&
184 git init -q gitrepo &&
187 echo alpha > alpha &&
189 git commit -q -m "add alpha" &&
190 git checkout -q -b not-master
194 hg_clone gitrepo hgrepo &&
199 hg -q commit -m "rename alpha to beta" &&
200 hg branch gamma | grep -v "permanent and global" &&
201 hg -q commit -m "started branch gamma"
204 hg_push hgrepo gitrepo &&
205 hg_clone gitrepo hgrepo2 &&
207 : Back to the common revision &&
208 (cd hgrepo && hg checkout default) &&
210 hg_log hgrepo > expected &&
211 hg_log hgrepo2 > actual &&
213 test_cmp expected actual
216 test_expect_success
'hg tags' '
217 mkdir -p tmp && cd tmp &&
218 test_when_finished "cd .. && rm -rf tmp" &&
221 git init -q gitrepo &&
224 echo alpha > alpha &&
226 git commit -m "add alpha" &&
227 git checkout -q -b not-master
231 hg_clone gitrepo hgrepo &&
238 hg_push hgrepo gitrepo &&
239 hg_clone gitrepo hgrepo2 &&
241 hg_log hgrepo > expected &&
242 hg_log hgrepo2 > actual &&
244 test_cmp expected actual