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'
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'
25 git
--git-dir=$1/.git log
--format='%s' -1 $2 > actual
26 test_cmp expected actual
31 hg
-R $1 log
-r $2 --template '{desc}\n' > actual
&&
32 test_cmp expected actual
37 hg
-R $1 log
-r "bookmark('$2')" --template '{desc}\n' > actual
&&
38 test_cmp expected actual
44 echo "username = H G Wells <wells@example.com>"
49 GIT_AUTHOR_DATE
="2007-01-01 00:00:00 +0230" &&
50 GIT_COMMITTER_DATE
="$GIT_AUTHOR_DATE" &&
51 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
56 test_expect_success
'cloning' '
57 test_when_finished "rm -rf gitrepo*" &&
62 echo zero > content &&
67 git clone "hg::hgrepo" gitrepo &&
68 check gitrepo HEAD zero
71 test_expect_success
'cloning with branches' '
72 test_when_finished "rm -rf gitrepo*" &&
77 echo next > content &&
81 git clone "hg::hgrepo" gitrepo &&
82 check gitrepo origin/branches/next next
85 test_expect_success
'cloning with bookmarks' '
86 test_when_finished "rm -rf gitrepo*" &&
90 hg checkout default &&
91 hg bookmark feature-a &&
92 echo feature-a > content &&
93 hg commit -m feature-a
96 git clone "hg::hgrepo" gitrepo &&
97 check gitrepo origin/feature-a feature-a
100 test_expect_success
'update bookmark' '
101 test_when_finished "rm -rf gitrepo*" &&
109 git clone "hg::hgrepo" gitrepo &&
111 git checkout --quiet devel &&
112 echo devel > content &&
113 git commit -a -m devel &&
117 check_bookmark hgrepo devel devel
120 test_expect_success
'new bookmark' '
121 test_when_finished "rm -rf gitrepo*" &&
124 git clone "hg::hgrepo" gitrepo &&
126 git checkout --quiet -b feature-b &&
127 echo feature-b > content &&
128 git commit -a -m feature-b &&
129 git push --quiet origin feature-b
132 check_bookmark hgrepo feature-b feature-b
135 # cleanup previous stuff
139 echo $1 >> content
&&
140 hg commit
-u "$2" -m "add $1" &&
141 echo "$3" >> ..
/expected
144 test_expect_success
'authors' '
145 test_when_finished "rm -rf hgrepo gitrepo" &&
155 author_test alpha "" "H G Wells <wells@example.com>" &&
156 author_test beta "test" "test <unknown>" &&
157 author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
158 author_test gamma "<test@example.com>" "Unknown <test@example.com>" &&
159 author_test delta "name<test@example.com>" "name <test@example.com>" &&
160 author_test epsilon "name <test@example.com" "name <test@example.com>" &&
161 author_test zeta " test " "test <unknown>" &&
162 author_test eta "test < test@example.com >" "test <test@example.com>" &&
163 author_test theta "test >test@example.com>" "test <test@example.com>" &&
164 author_test iota "test < test <at> example <dot> com>" "test <unknown>" &&
165 author_test kappa "test@example.com" "Unknown <test@example.com>"
168 git clone "hg::hgrepo" gitrepo &&
169 git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
171 test_cmp expected actual
174 test_expect_success
'strip' '
175 test_when_finished "rm -rf hgrepo gitrepo" &&
181 echo one >> content &&
185 echo two >> content &&
189 git clone "hg::hgrepo" gitrepo &&
195 echo three >> content &&
196 hg commit -m three &&
198 echo four >> content &&
205 git log --format="%s" origin/master > ../actual
208 hg -R hgrepo log --template "{desc}\n" > expected &&
209 test_cmp actual expected
212 test_expect_success
'remote push with master bookmark' '
213 test_when_finished "rm -rf hgrepo gitrepo*" &&
218 echo zero > content &&
221 hg bookmark master &&
222 echo one > content &&
227 git clone "hg::hgrepo" gitrepo &&
229 echo two > content &&
230 git commit -a -m two &&
234 check_branch hgrepo default two
238 changeset: 0:6e2126489d3d
240 user: A U Thor <author@example.com>
241 date: Mon Jan 01 00:00:00 2007 +0230
246 test_expect_success
'remote push from master branch' '
247 test_when_finished "rm -rf hgrepo gitrepo*" &&
254 git remote add origin "hg::../hgrepo" &&
255 echo one > content &&
257 git commit -a -m one &&
258 git push origin master
261 hg -R hgrepo log > actual &&
263 test_cmp expected actual &&
265 check_branch hgrepo default one
268 GIT_REMOTE_HG_TEST_REMOTE
=1
269 export GIT_REMOTE_HG_TEST_REMOTE
271 test_expect_success
'remote cloning' '
272 test_when_finished "rm -rf gitrepo*" &&
277 echo zero > content &&
282 git clone "hg::hgrepo" gitrepo &&
283 check gitrepo HEAD zero
286 test_expect_success
'remote update bookmark' '
287 test_when_finished "rm -rf gitrepo*" &&
295 git clone "hg::hgrepo" gitrepo &&
297 git checkout --quiet devel &&
298 echo devel > content &&
299 git commit -a -m devel &&
303 check_bookmark hgrepo devel devel
306 test_expect_success
'remote new bookmark' '
307 test_when_finished "rm -rf gitrepo*" &&
310 git clone "hg::hgrepo" gitrepo &&
312 git checkout --quiet -b feature-b &&
313 echo feature-b > content &&
314 git commit -a -m feature-b &&
315 git push --quiet origin feature-b
318 check_bookmark hgrepo feature-b feature-b