fixup-builtins: retire an old transition helper script
[alt-git.git] / contrib / remote-helpers / test-bzr.sh
blob5dfa070b64e6e4607adaa436d4aa839c9de5f9e4
1 #!/bin/sh
3 # Copyright (c) 2012 Felipe Contreras
6 test_description='Test remote-bzr'
8 . ./test-lib.sh
10 if ! test_have_prereq PYTHON; then
11 skip_all='skipping remote-bzr tests; python not available'
12 test_done
15 if ! "$PYTHON_PATH" -c 'import bzrlib'; then
16 skip_all='skipping remote-bzr tests; bzr not available'
17 test_done
20 check () {
21 (cd $1 &&
22 git log --format='%s' -1 &&
23 git symbolic-ref HEAD) > actual &&
24 (echo $2 &&
25 echo "refs/heads/$3") > expected &&
26 test_cmp expected actual
29 bzr whoami "A U Thor <author@example.com>"
31 test_expect_success 'cloning' '
32 (bzr init bzrrepo &&
33 cd bzrrepo &&
34 echo one > content &&
35 bzr add content &&
36 bzr commit -m one
37 ) &&
39 git clone "bzr::$PWD/bzrrepo" gitrepo &&
40 check gitrepo one master
43 test_expect_success 'pulling' '
44 (cd bzrrepo &&
45 echo two > content &&
46 bzr commit -m two
47 ) &&
49 (cd gitrepo && git pull) &&
51 check gitrepo two master
54 test_expect_success 'pushing' '
55 (cd gitrepo &&
56 echo three > content &&
57 git commit -a -m three &&
58 git push
59 ) &&
61 echo three > expected &&
62 cat bzrrepo/content > actual &&
63 test_cmp expected actual
66 test_expect_success 'roundtrip' '
67 (cd gitrepo &&
68 git pull &&
69 git log --format="%s" -1 origin/master > actual) &&
70 echo three > expected &&
71 test_cmp expected actual &&
73 (cd gitrepo && git push && git pull) &&
75 (cd bzrrepo &&
76 echo four > content &&
77 bzr commit -m four
78 ) &&
80 (cd gitrepo && git pull && git push) &&
82 check gitrepo four master &&
84 (cd gitrepo &&
85 echo five > content &&
86 git commit -a -m five &&
87 git push && git pull
88 ) &&
90 (cd bzrrepo && bzr revert) &&
92 echo five > expected &&
93 cat bzrrepo/content > actual &&
94 test_cmp expected actual
97 cat > expected <<EOF
98 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
99 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
100 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
103 test_expect_success 'special modes' '
104 (cd bzrrepo &&
105 echo exec > executable
106 chmod +x executable &&
107 bzr add executable
108 bzr commit -m exec &&
109 ln -s content link
110 bzr add link
111 bzr commit -m link &&
112 mkdir dir &&
113 bzr add dir &&
114 bzr commit -m dir) &&
116 (cd gitrepo &&
117 git pull
118 git ls-tree HEAD > ../actual) &&
120 test_cmp expected actual &&
122 (cd gitrepo &&
123 git cat-file -p HEAD:link > ../actual) &&
125 printf content > expected &&
126 test_cmp expected actual
129 cat > expected <<EOF
130 100644 blob 54f9d6da5c91d556e6b54340b1327573073030af content
131 100755 blob 68769579c3eaadbe555379b9c3538e6628bae1eb executable
132 120000 blob 6b584e8ece562ebffc15d38808cd6b98fc3d97ea link
133 040000 tree 35c0caa46693cef62247ac89a680f0c5ce32b37b movedir-new
136 test_expect_success 'moving directory' '
137 (cd bzrrepo &&
138 mkdir movedir &&
139 echo one > movedir/one &&
140 echo two > movedir/two &&
141 bzr add movedir &&
142 bzr commit -m movedir &&
143 bzr mv movedir movedir-new &&
144 bzr commit -m movedir-new) &&
146 (cd gitrepo &&
147 git pull &&
148 git ls-tree HEAD > ../actual) &&
150 test_cmp expected actual
153 test_expect_success 'different authors' '
154 (cd bzrrepo &&
155 echo john >> content &&
156 bzr commit -m john \
157 --author "Jane Rey <jrey@example.com>" \
158 --author "John Doe <jdoe@example.com>") &&
160 (cd gitrepo &&
161 git pull &&
162 git show --format="%an <%ae>, %cn <%ce>" --quiet > ../actual) &&
164 echo "Jane Rey <jrey@example.com>, A U Thor <author@example.com>" > expected &&
165 test_cmp expected actual
168 test_expect_success 'fetch utf-8 filenames' '
169 mkdir -p tmp && cd tmp &&
170 test_when_finished "cd .. && rm -rf tmp && LC_ALL=C" &&
172 LC_ALL=en_US.UTF-8
173 export LC_ALL
175 bzr init bzrrepo &&
176 cd bzrrepo &&
178 echo test >> "ærø" &&
179 bzr add "ærø" &&
180 echo test >> "ø~?" &&
181 bzr add "ø~?" &&
182 bzr commit -m add-utf-8 &&
183 echo test >> "ærø" &&
184 bzr commit -m test-utf-8 &&
185 bzr rm "ø~?" &&
186 bzr mv "ærø" "ø~?" &&
187 bzr commit -m bzr-mv-utf-8
188 ) &&
191 git clone "bzr::$PWD/bzrrepo" gitrepo &&
192 cd gitrepo &&
193 git -c core.quotepath=false ls-files > ../actual
194 ) &&
195 echo "ø~?" > expected &&
196 test_cmp expected actual
199 test_expect_success 'push utf-8 filenames' '
200 mkdir -p tmp && cd tmp &&
201 test_when_finished "cd .. && rm -rf tmp && LC_ALL=C" &&
203 LC_ALL=en_US.UTF-8
204 export LC_ALL
207 bzr init bzrrepo &&
208 cd bzrrepo &&
210 echo one >> content &&
211 bzr add content &&
212 bzr commit -m one
213 ) &&
216 git clone "bzr::$PWD/bzrrepo" gitrepo &&
217 cd gitrepo &&
219 echo test >> "ærø" &&
220 git add "ærø" &&
221 git commit -m utf-8 &&
223 git push
224 ) &&
226 (cd bzrrepo && bzr ls > ../actual) &&
227 printf "content\nærø\n" > expected &&
228 test_cmp expected actual
231 test_expect_success 'pushing a merge' '
232 mkdir -p tmp && cd tmp &&
233 test_when_finished "cd .. && rm -rf tmp" &&
236 bzr init bzrrepo &&
237 cd bzrrepo &&
238 echo one > content &&
239 bzr add content &&
240 bzr commit -m one
241 ) &&
243 git clone "bzr::$PWD/bzrrepo" gitrepo &&
246 cd bzrrepo &&
247 echo two > content &&
248 bzr commit -m two
249 ) &&
252 cd gitrepo &&
253 echo three > content &&
254 git commit -a -m three &&
255 git fetch &&
256 git merge origin/master || true &&
257 echo three > content &&
258 git commit -a --no-edit &&
259 git push
260 ) &&
262 echo three > expected &&
263 cat bzrrepo/content > actual &&
264 test_cmp expected actual
267 cat > expected <<EOF
268 origin/HEAD
269 origin/branch
270 origin/trunk
273 test_expect_success 'proper bzr repo' '
274 mkdir -p tmp && cd tmp &&
275 test_when_finished "cd .. && rm -rf tmp" &&
277 bzr init-repo bzrrepo &&
279 bzr init bzrrepo/trunk &&
281 cd bzrrepo/trunk &&
282 echo one >> content &&
283 bzr add content &&
284 bzr commit -m one
285 ) &&
287 bzr branch bzrrepo/trunk bzrrepo/branch &&
289 cd bzrrepo/branch &&
290 echo two >> content &&
291 bzr commit -m one
292 ) &&
294 git clone "bzr::$PWD/bzrrepo" gitrepo &&
296 cd gitrepo &&
297 git for-each-ref --format "%(refname:short)" refs/remotes/origin > ../actual
298 ) &&
300 test_cmp ../expected actual
303 test_expect_success 'strip' '
304 # Do not imitate this style; always chdir inside a subshell instead
305 mkdir -p tmp && cd tmp &&
306 test_when_finished "cd .. && rm -rf tmp" &&
309 bzr init bzrrepo &&
310 cd bzrrepo &&
312 echo one >> content &&
313 bzr add content &&
314 bzr commit -m one &&
316 echo two >> content &&
317 bzr commit -m two
318 ) &&
320 git clone "bzr::$PWD/bzrrepo" gitrepo &&
323 cd bzrrepo &&
324 bzr uncommit --force &&
326 echo three >> content &&
327 bzr commit -m three &&
329 echo four >> content &&
330 bzr commit -m four &&
331 bzr log --line | sed -e "s/^[0-9][0-9]*: //" > ../expected
332 ) &&
334 (cd gitrepo &&
335 git fetch &&
336 git log --format="%an %ad %s" --date=short origin/master > ../actual) &&
338 test_cmp expected actual
341 test_done