##// 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
2
7
3 cat > $HGRCPATH <<EOF
8 Set up helpers
4 [diff]
9
5 git = 1
10 $ seteol () {
6 EOF
11 > if [ $1 = "LF" ]; then
12 > EOL='\n'
13 > else
14 > EOL='\r\n'
15 > fi
16 > }
7
17
8 seteol () {
18 $ makerepo () {
9 if [ $1 = "LF" ]; then
19 > seteol $1
10 EOL='\n'
20 > echo
11 else
21 > echo "# ==== setup $1 repository ===="
12 EOL='\r\n'
22 > echo '% hg init'
13 fi
23 > hg init repo
14 }
24 > cd repo
15
25 > cat > .hgeol <<EOF
16 makerepo () {
26 > [repository]
17 seteol $1
27 > native = $1
18 echo
28 > [patterns]
19 echo "# ==== setup $1 repository ===="
29 > unix.txt = LF
20 echo '% hg init'
30 > win.txt = CRLF
21 hg init repo
31 > **.txt = native
22 cd repo
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 > }
23
39
24 cat > .hgeol <<EOF
40 $ dotest () {
25 [repository]
41 > seteol $1
26 native = $1
42 > echo
27
43 > echo "% hg clone repo repo-$1"
28 [patterns]
44 > hg clone --noupdate repo repo-$1
29 unix.txt = LF
45 > cd repo-$1
30 win.txt = CRLF
46 > cat > .hg/hgrc <<EOF
31 **.txt = native
47 > [extensions]
32 EOF
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 > }
33
80
34 printf "first\r\nsecond\r\nthird\r\n" > win.txt
81 Run tests
35 printf "first\nsecond\nthird\n" > unix.txt
36 printf "first${EOL}second${EOL}third${EOL}" > native.txt
37 hg commit --addremove -m 'checkin'
38 cd ..
39 }
40
41 dotest () {
42 seteol $1
43
44 echo
45 echo "% hg clone repo repo-$1"
46 hg clone --noupdate repo repo-$1
47 cd repo-$1
48
49 cat > .hg/hgrc <<EOF
50 [extensions]
51 eol =
52
82
53 [eol]
83 $ makerepo LF
54 native = $1
84
55 EOF
85 # ==== setup LF repository ====
56
86 % hg init
57 hg update
87 adding .hgeol
58 echo '% printrepr.py native.txt'
88 adding native.txt
59 python $TESTDIR/printrepr.py < native.txt
89 adding unix.txt
60
90 adding win.txt
61 echo '% printrepr.py unix.txt'
91 $ dotest LF
62 python $TESTDIR/printrepr.py < unix.txt
92
63
93 % hg clone repo repo-LF
64 echo '% printrepr.py win.txt'
94 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
65 python $TESTDIR/printrepr.py < win.txt
95 % printrepr.py native.txt
66
96 first
67 printf "first${EOL}third${EOL}" > native.txt
97 second
68 printf "first\r\nthird\r\n" > win.txt
98 third
69 printf "first\nthird\n" > unix.txt
99 % printrepr.py unix.txt
70
100 first
71 echo '% hg diff'
101 second
72 hg diff > p
102 third
73 python $TESTDIR/printrepr.py < p
103 % printrepr.py win.txt
74
104 first\r
75 echo '% hg revert'
105 second\r
76 hg revert --all
106 third\r
77
107 % hg diff
78 echo '% hg import'
108 diff --git a/native.txt b/native.txt
79 hg import -m 'patch' p
109 --- a/native.txt
80
110 +++ b/native.txt
81 echo '% printrepr.py native.txt'
111 @@ -1,3 +1,2 @@
82 python $TESTDIR/printrepr.py < native.txt
112 first
83 echo '% printrepr.py unix.txt'
113 -second
84 python $TESTDIR/printrepr.py < unix.txt
114 third
85 echo '% printrepr.py win.txt'
115 diff --git a/unix.txt b/unix.txt
86 python $TESTDIR/printrepr.py < win.txt
116 --- a/unix.txt
87
117 +++ b/unix.txt
88 echo '% hg diff -c tip'
118 @@ -1,3 +1,2 @@
89 hg diff -c tip | python $TESTDIR/printrepr.py
119 first
90
120 -second
91 cd ..
121 third
92 rm -r repo-$1
122 diff --git a/win.txt b/win.txt
93 }
123 --- a/win.txt
94
124 +++ b/win.txt
95 makerepo LF
125 @@ -1,3 +1,2 @@
96 dotest LF
126 first\r
97 dotest CRLF
127 -second\r
98 rm -r repo
128 third\r
99
129 % hg revert
100 makerepo CRLF
130 reverting native.txt
101 dotest LF
131 reverting unix.txt
102 dotest CRLF
132 reverting win.txt
103 rm -r repo
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
167
168 % hg clone repo repo-CRLF
169 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
170 % printrepr.py native.txt
171 first\r
172 second\r
173 third\r
174 % printrepr.py unix.txt
175 first
176 second
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
243
244 # ==== setup CRLF repository ====
245 % hg init
246 adding .hgeol
247 adding native.txt
248 adding unix.txt
249 adding win.txt
250 $ dotest LF
251
252 % hg clone repo repo-LF
253 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
254 % printrepr.py native.txt
255 first
256 second
257 third
258 % printrepr.py unix.txt
259 first
260 second
261 third
262 % printrepr.py win.txt
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
326
327 % hg clone repo repo-CRLF
328 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
329 % printrepr.py native.txt
330 first\r
331 second\r
332 third\r
333 % printrepr.py unix.txt
334 first
335 second
336 third
337 % printrepr.py win.txt
338 first\r
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