3 # Copyright (c) 2012 Felipe Contreras
6 test_description
='Test remote-bzr'
10 if ! test_have_prereq PYTHON
; then
11 skip_all
='skipping remote-bzr tests; python not available'
15 if ! python
-c 'import bzrlib'; then
16 skip_all
='skipping remote-bzr tests; bzr not available'
22 git
--git-dir=$1/.git log
--format='%s' -1 $2 > actual
23 test_cmp expected actual
26 bzr whoami
"A U Thor <author@example.com>"
28 test_expect_success
'cloning' '
37 git clone "bzr::bzrrepo" gitrepo &&
38 check gitrepo HEAD one
41 test_expect_success
'pulling' '
48 (cd gitrepo && git pull) &&
50 check gitrepo HEAD two
53 test_expect_success
'pushing' '
56 echo three > content &&
57 git commit -a -m three &&
61 echo three > expected &&
62 cat bzrrepo/content > actual &&
63 test_cmp expected actual
66 test_expect_success
'roundtrip' '
70 git log --format="%s" -1 origin/master > actual
72 echo three > expected &&
73 test_cmp expected actual &&
75 (cd gitrepo && git push && git pull) &&
79 echo four > content &&
83 (cd gitrepo && git pull && git push) &&
85 check gitrepo HEAD four &&
89 echo five > content &&
90 git commit -a -m five &&
94 (cd bzrrepo && bzr revert) &&
96 echo five > expected &&
97 cat bzrrepo/content > actual &&
98 test_cmp expected actual
102 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
103 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
104 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
107 test_expect_success
'special modes' '
110 echo exec > executable
111 chmod +x executable &&
113 bzr commit -m exec &&
116 bzr commit -m link &&
125 git ls-tree HEAD > ../actual
128 test_cmp expected actual &&
132 git cat-file -p HEAD:link > ../actual
135 printf content > expected &&
136 test_cmp expected actual
140 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
141 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
142 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
143 040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b movedir-new
146 test_expect_success
'moving directory' '
150 echo one > movedir/one &&
151 echo two > movedir/two &&
153 bzr commit -m movedir &&
154 bzr mv movedir movedir-new &&
155 bzr commit -m movedir-new
161 git ls-tree HEAD > ../actual
164 test_cmp expected actual
167 test_expect_success
'different authors' '
170 echo john >> content &&
172 --author "Jane Rey <jrey@example.com>" \
173 --author "John Doe <jdoe@example.com>"
179 git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual
182 echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
183 test_cmp expected actual
186 # cleanup previous stuff
187 rm -rf bzrrepo gitrepo
189 test_expect_success
'fetch utf-8 filenames' '
190 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
199 echo test >> "ærø" &&
201 echo test >> "ø~?" &&
203 bzr commit -m add-utf-8 &&
204 echo test >> "ærø" &&
205 bzr commit -m test-utf-8 &&
207 bzr mv "ærø" "ø~?" &&
208 bzr commit -m bzr-mv-utf-8
212 git clone "bzr::bzrrepo" gitrepo &&
214 git -c core.quotepath=false ls-files > ../actual
216 echo "ø~?" > expected &&
217 test_cmp expected actual
220 test_expect_success
'push utf-8 filenames' '
221 test_when_finished "rm -rf bzrrepo gitrepo && LC_ALL=C" &&
223 mkdir -p tmp && cd tmp &&
232 echo one >> content &&
238 git clone "bzr::bzrrepo" gitrepo &&
241 echo test >> "ærø" &&
243 git commit -m utf-8 &&
248 (cd bzrrepo && bzr ls > ../actual) &&
249 printf "content\nærø\n" > expected &&
250 test_cmp expected actual
253 test_expect_success
'pushing a merge' '
254 test_when_finished "rm -rf bzrrepo gitrepo" &&
259 echo one > content &&
264 git clone "bzr::bzrrepo" gitrepo &&
268 echo two > content &&
274 echo three > content &&
275 git commit -a -m three &&
277 git merge origin/master || true &&
278 echo three > content &&
279 git commit -a --no-edit &&
283 echo three > expected &&
284 cat bzrrepo/content > actual &&
285 test_cmp expected actual
294 test_expect_success
'proper bzr repo' '
295 test_when_finished "rm -rf bzrrepo gitrepo" &&
297 bzr init-repo bzrrepo &&
300 bzr init bzrrepo/trunk &&
302 echo one >> content &&
308 bzr branch bzrrepo/trunk bzrrepo/branch &&
310 echo two >> content &&
315 git clone "bzr::bzrrepo" gitrepo &&
317 git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
320 test_cmp expected actual
323 test_expect_success
'strip' '
324 test_when_finished "rm -rf bzrrepo gitrepo" &&
330 echo one >> content &&
334 echo two >> content &&
338 git clone "bzr::bzrrepo" gitrepo &&
342 bzr uncommit --force &&
344 echo three >> content &&
345 bzr commit -m three &&
347 echo four >> content &&
348 bzr commit -m four &&
349 bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
355 git log --format="%an %ad %s" --date=short origin/master > ../actual
358 test_cmp expected actual