##// END OF EJS Templates
tests: unify test-eol-patch
Matt Mackall -
r12420:e9db6bc3 default
parent child Browse files
Show More
@@ -1,103 +1,400 b''
1 #!/bin/sh
1 Test EOL patching
2
3 $ cat > $HGRCPATH <<EOF
4 > [diff]
5 > git = 1
6 > EOF
7
8 Set up helpers
9
10 $ seteol () {
11 > if [ $1 = "LF" ]; then
12 > EOL='\n'
13 > else
14 > EOL='\r\n'
15 > fi
16 > }
2
17
3 cat > $HGRCPATH <<EOF
18 $ makerepo () {
4 [diff]
19 > seteol $1
5 git = 1
20 > echo
6 EOF
21 > echo "# ==== setup $1 repository ===="
22 > echo '% hg init'
23 > hg init repo
24 > cd repo
25 > cat > .hgeol <<EOF
26 > [repository]
27 > native = $1
28 > [patterns]
29 > unix.txt = LF
30 > win.txt = CRLF
31 > **.txt = native
32 > EOF
33 > printf "first\r\nsecond\r\nthird\r\n" > win.txt
34 > printf "first\nsecond\nthird\n" > unix.txt
35 > printf "first${EOL}second${EOL}third${EOL}" > native.txt
36 > hg commit --addremove -m 'checkin'
37 > cd ..
38 > }
7
39
8 seteol () {
40 $ dotest () {
9 if [ $1 = "LF" ]; then
41 > seteol $1
10 EOL='\n'
42 > echo
11 else
43 > echo "% hg clone repo repo-$1"
12 EOL='\r\n'
44 > hg clone --noupdate repo repo-$1
13 fi
45 > cd repo-$1
14 }
46 > cat > .hg/hgrc <<EOF
47 > [extensions]
48 > eol =
49 > [eol]
50 > native = $1
51 > EOF
52 > hg update
53 > echo '% printrepr.py native.txt'
54 > python $TESTDIR/printrepr.py < native.txt
55 > echo '% printrepr.py unix.txt'
56 > python $TESTDIR/printrepr.py < unix.txt
57 > echo '% printrepr.py win.txt'
58 > python $TESTDIR/printrepr.py < win.txt
59 > printf "first${EOL}third${EOL}" > native.txt
60 > printf "first\r\nthird\r\n" > win.txt
61 > printf "first\nthird\n" > unix.txt
62 > echo '% hg diff'
63 > hg diff > p
64 > python $TESTDIR/printrepr.py < p
65 > echo '% hg revert'
66 > hg revert --all
67 > echo '% hg import'
68 > hg import -m 'patch' p
69 > echo '% printrepr.py native.txt'
70 > python $TESTDIR/printrepr.py < native.txt
71 > echo '% printrepr.py unix.txt'
72 > python $TESTDIR/printrepr.py < unix.txt
73 > echo '% printrepr.py win.txt'
74 > python $TESTDIR/printrepr.py < win.txt
75 > echo '% hg diff -c tip'
76 > hg diff -c tip | python $TESTDIR/printrepr.py
77 > cd ..
78 > rm -r repo-$1
79 > }
15
80
16 makerepo () {
81 Run tests
17 seteol $1
18 echo
19 echo "# ==== setup $1 repository ===="
20 echo '% hg init'
21 hg init repo
22 cd repo
23
82
24 cat > .hgeol <<EOF
83 $ makerepo LF
25 [repository]
26 native = $1
27
84
28 [patterns]
85 # ==== setup LF repository ====
29 unix.txt = LF
86 % hg init
30 win.txt = CRLF
87 adding .hgeol
31 **.txt = native
88 adding native.txt
32 EOF
89 adding unix.txt
90 adding win.txt
91 $ dotest LF
33
92
34 printf "first\r\nsecond\r\nthird\r\n" > win.txt
93 % hg clone repo repo-LF
35 printf "first\nsecond\nthird\n" > unix.txt
94 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
36 printf "first${EOL}second${EOL}third${EOL}" > native.txt
95 % printrepr.py native.txt
37 hg commit --addremove -m 'checkin'
96 first
38 cd ..
97 second
39 }
98 third
40
99 % printrepr.py unix.txt
41 dotest () {
100 first
42 seteol $1
101 second
43
102 third
44 echo
103 % printrepr.py win.txt
45 echo "% hg clone repo repo-$1"
104 first\r
46 hg clone --noupdate repo repo-$1
105 second\r
47 cd repo-$1
106 third\r
48
107 % hg diff
49 cat > .hg/hgrc <<EOF
108 diff --git a/native.txt b/native.txt
50 [extensions]
109 --- a/native.txt
51 eol =
110 +++ b/native.txt
111 @@ -1,3 +1,2 @@
112 first
113 -second
114 third
115 diff --git a/unix.txt b/unix.txt
116 --- a/unix.txt
117 +++ b/unix.txt
118 @@ -1,3 +1,2 @@
119 first
120 -second
121 third
122 diff --git a/win.txt b/win.txt
123 --- a/win.txt
124 +++ b/win.txt
125 @@ -1,3 +1,2 @@
126 first\r
127 -second\r
128 third\r
129 % hg revert
130 reverting native.txt
131 reverting unix.txt
132 reverting win.txt
133 % hg import
134 applying p
135 % printrepr.py native.txt
136 first
137 third
138 % printrepr.py unix.txt
139 first
140 third
141 % printrepr.py win.txt
142 first\r
143 third\r
144 % hg diff -c tip
145 diff --git a/native.txt b/native.txt
146 --- a/native.txt
147 +++ b/native.txt
148 @@ -1,3 +1,2 @@
149 first
150 -second
151 third
152 diff --git a/unix.txt b/unix.txt
153 --- a/unix.txt
154 +++ b/unix.txt
155 @@ -1,3 +1,2 @@
156 first
157 -second
158 third
159 diff --git a/win.txt b/win.txt
160 --- a/win.txt
161 +++ b/win.txt
162 @@ -1,3 +1,2 @@
163 first\r
164 -second\r
165 third\r
166 $ dotest CRLF
52
167
53 [eol]
168 % hg clone repo repo-CRLF
54 native = $1
169 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
55 EOF
170 % printrepr.py native.txt
56
171 first\r
57 hg update
172 second\r
58 echo '% printrepr.py native.txt'
173 third\r
59 python $TESTDIR/printrepr.py < native.txt
174 % printrepr.py unix.txt
60
175 first
61 echo '% printrepr.py unix.txt'
176 second
62 python $TESTDIR/printrepr.py < unix.txt
177 third
178 % printrepr.py win.txt
179 first\r
180 second\r
181 third\r
182 % hg diff
183 diff --git a/native.txt b/native.txt
184 --- a/native.txt
185 +++ b/native.txt
186 @@ -1,3 +1,2 @@
187 first
188 -second
189 third
190 diff --git a/unix.txt b/unix.txt
191 --- a/unix.txt
192 +++ b/unix.txt
193 @@ -1,3 +1,2 @@
194 first
195 -second
196 third
197 diff --git a/win.txt b/win.txt
198 --- a/win.txt
199 +++ b/win.txt
200 @@ -1,3 +1,2 @@
201 first\r
202 -second\r
203 third\r
204 % hg revert
205 reverting native.txt
206 reverting unix.txt
207 reverting win.txt
208 % hg import
209 applying p
210 % printrepr.py native.txt
211 first\r
212 third\r
213 % printrepr.py unix.txt
214 first
215 third
216 % printrepr.py win.txt
217 first\r
218 third\r
219 % hg diff -c tip
220 diff --git a/native.txt b/native.txt
221 --- a/native.txt
222 +++ b/native.txt
223 @@ -1,3 +1,2 @@
224 first
225 -second
226 third
227 diff --git a/unix.txt b/unix.txt
228 --- a/unix.txt
229 +++ b/unix.txt
230 @@ -1,3 +1,2 @@
231 first
232 -second
233 third
234 diff --git a/win.txt b/win.txt
235 --- a/win.txt
236 +++ b/win.txt
237 @@ -1,3 +1,2 @@
238 first\r
239 -second\r
240 third\r
241 $ rm -r repo
242 $ makerepo CRLF
63
243
64 echo '% printrepr.py win.txt'
244 # ==== setup CRLF repository ====
65 python $TESTDIR/printrepr.py < win.txt
245 % hg init
66
246 adding .hgeol
67 printf "first${EOL}third${EOL}" > native.txt
247 adding native.txt
68 printf "first\r\nthird\r\n" > win.txt
248 adding unix.txt
69 printf "first\nthird\n" > unix.txt
249 adding win.txt
70
250 $ dotest LF
71 echo '% hg diff'
72 hg diff > p
73 python $TESTDIR/printrepr.py < p
74
75 echo '% hg revert'
76 hg revert --all
77
251
78 echo '% hg import'
252 % hg clone repo repo-LF
79 hg import -m 'patch' p
253 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
80
254 % printrepr.py native.txt
81 echo '% printrepr.py native.txt'
255 first
82 python $TESTDIR/printrepr.py < native.txt
256 second
83 echo '% printrepr.py unix.txt'
257 third
84 python $TESTDIR/printrepr.py < unix.txt
258 % printrepr.py unix.txt
85 echo '% printrepr.py win.txt'
259 first
86 python $TESTDIR/printrepr.py < win.txt
260 second
87
261 third
88 echo '% hg diff -c tip'
262 % printrepr.py win.txt
89 hg diff -c tip | python $TESTDIR/printrepr.py
263 first\r
264 second\r
265 third\r
266 % hg diff
267 diff --git a/native.txt b/native.txt
268 --- a/native.txt
269 +++ b/native.txt
270 @@ -1,3 +1,2 @@
271 first\r
272 -second\r
273 third\r
274 diff --git a/unix.txt b/unix.txt
275 --- a/unix.txt
276 +++ b/unix.txt
277 @@ -1,3 +1,2 @@
278 first
279 -second
280 third
281 diff --git a/win.txt b/win.txt
282 --- a/win.txt
283 +++ b/win.txt
284 @@ -1,3 +1,2 @@
285 first\r
286 -second\r
287 third\r
288 % hg revert
289 reverting native.txt
290 reverting unix.txt
291 reverting win.txt
292 % hg import
293 applying p
294 % printrepr.py native.txt
295 first
296 third
297 % printrepr.py unix.txt
298 first
299 third
300 % printrepr.py win.txt
301 first\r
302 third\r
303 % hg diff -c tip
304 diff --git a/native.txt b/native.txt
305 --- a/native.txt
306 +++ b/native.txt
307 @@ -1,3 +1,2 @@
308 first\r
309 -second\r
310 third\r
311 diff --git a/unix.txt b/unix.txt
312 --- a/unix.txt
313 +++ b/unix.txt
314 @@ -1,3 +1,2 @@
315 first
316 -second
317 third
318 diff --git a/win.txt b/win.txt
319 --- a/win.txt
320 +++ b/win.txt
321 @@ -1,3 +1,2 @@
322 first\r
323 -second\r
324 third\r
325 $ dotest CRLF
90
326
91 cd ..
327 % hg clone repo repo-CRLF
92 rm -r repo-$1
328 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
93 }
329 % printrepr.py native.txt
94
330 first\r
95 makerepo LF
331 second\r
96 dotest LF
332 third\r
97 dotest CRLF
333 % printrepr.py unix.txt
98 rm -r repo
334 first
99
335 second
100 makerepo CRLF
336 third
101 dotest LF
337 % printrepr.py win.txt
102 dotest CRLF
338 first\r
103 rm -r repo
339 second\r
340 third\r
341 % hg diff
342 diff --git a/native.txt b/native.txt
343 --- a/native.txt
344 +++ b/native.txt
345 @@ -1,3 +1,2 @@
346 first\r
347 -second\r
348 third\r
349 diff --git a/unix.txt b/unix.txt
350 --- a/unix.txt
351 +++ b/unix.txt
352 @@ -1,3 +1,2 @@
353 first
354 -second
355 third
356 diff --git a/win.txt b/win.txt
357 --- a/win.txt
358 +++ b/win.txt
359 @@ -1,3 +1,2 @@
360 first\r
361 -second\r
362 third\r
363 % hg revert
364 reverting native.txt
365 reverting unix.txt
366 reverting win.txt
367 % hg import
368 applying p
369 % printrepr.py native.txt
370 first\r
371 third\r
372 % printrepr.py unix.txt
373 first
374 third
375 % printrepr.py win.txt
376 first\r
377 third\r
378 % hg diff -c tip
379 diff --git a/native.txt b/native.txt
380 --- a/native.txt
381 +++ b/native.txt
382 @@ -1,3 +1,2 @@
383 first\r
384 -second\r
385 third\r
386 diff --git a/unix.txt b/unix.txt
387 --- a/unix.txt
388 +++ b/unix.txt
389 @@ -1,3 +1,2 @@
390 first
391 -second
392 third
393 diff --git a/win.txt b/win.txt
394 --- a/win.txt
395 +++ b/win.txt
396 @@ -1,3 +1,2 @@
397 first\r
398 -second\r
399 third\r
400 $ rm -r repo
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now