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 | |
|
4 | [diff] | |
|
5 | git = 1 | |
|
6 | EOF | |
|
8 | Set up helpers | |
|
9 | ||
|
10 | $ seteol () { | |
|
11 | > if [ $1 = "LF" ]; then | |
|
12 | > EOL='\n' | |
|
13 | > else | |
|
14 | > EOL='\r\n' | |
|
15 | > fi | |
|
16 | > } | |
|
7 | 17 | |
|
8 | seteol () { | |
|
9 | if [ $1 = "LF" ]; then | |
|
10 | EOL='\n' | |
|
11 | else | |
|
12 | EOL='\r\n' | |
|
13 | fi | |
|
14 | } | |
|
15 | ||
|
16 | makerepo () { | |
|
17 | seteol $1 | |
|
18 | echo | |
|
19 | echo "# ==== setup $1 repository ====" | |
|
20 | echo '% hg init' | |
|
21 | hg init repo | |
|
22 | cd repo | |
|
18 | $ makerepo () { | |
|
19 | > seteol $1 | |
|
20 | > echo | |
|
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 | > } | |
|
23 | 39 | |
|
24 | cat > .hgeol <<EOF | |
|
25 | [repository] | |
|
26 | native = $1 | |
|
27 | ||
|
28 | [patterns] | |
|
29 | unix.txt = LF | |
|
30 | win.txt = CRLF | |
|
31 | **.txt = native | |
|
32 | EOF | |
|
40 | $ dotest () { | |
|
41 | > seteol $1 | |
|
42 | > echo | |
|
43 | > echo "% hg clone repo repo-$1" | |
|
44 | > hg clone --noupdate repo repo-$1 | |
|
45 | > cd repo-$1 | |
|
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 | > } | |
|
33 | 80 | |
|
34 | printf "first\r\nsecond\r\nthird\r\n" > win.txt | |
|
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 = | |
|
81 | Run tests | |
|
52 | 82 | |
|
53 | [eol] | |
|
54 | native = $1 | |
|
55 | EOF | |
|
56 | ||
|
57 | hg update | |
|
58 | echo '% printrepr.py native.txt' | |
|
59 | python $TESTDIR/printrepr.py < native.txt | |
|
60 | ||
|
61 | echo '% printrepr.py unix.txt' | |
|
62 | python $TESTDIR/printrepr.py < unix.txt | |
|
63 | ||
|
64 | echo '% printrepr.py win.txt' | |
|
65 |
|
|
|
66 | ||
|
67 | printf "first${EOL}third${EOL}" > native.txt | |
|
68 | printf "first\r\nthird\r\n" > win.txt | |
|
69 |
|
|
|
70 | ||
|
71 | echo '% hg diff' | |
|
72 | hg diff > p | |
|
73 | python $TESTDIR/printrepr.py < p | |
|
74 | ||
|
75 | echo '% hg revert' | |
|
76 | hg revert --all | |
|
77 | ||
|
78 | echo '% hg import' | |
|
79 | hg import -m 'patch' p | |
|
80 | ||
|
81 | echo '% printrepr.py native.txt' | |
|
82 | python $TESTDIR/printrepr.py < native.txt | |
|
83 | echo '% printrepr.py unix.txt' | |
|
84 | python $TESTDIR/printrepr.py < unix.txt | |
|
85 | echo '% printrepr.py win.txt' | |
|
86 | python $TESTDIR/printrepr.py < win.txt | |
|
87 | ||
|
88 | echo '% hg diff -c tip' | |
|
89 | hg diff -c tip | python $TESTDIR/printrepr.py | |
|
90 | ||
|
91 | cd .. | |
|
92 | rm -r repo-$1 | |
|
93 | } | |
|
94 | ||
|
95 | makerepo LF | |
|
96 | dotest LF | |
|
97 | dotest CRLF | |
|
98 | rm -r repo | |
|
99 | ||
|
100 | makerepo CRLF | |
|
101 | dotest LF | |
|
102 | dotest CRLF | |
|
103 | rm -r repo | |
|
83 | $ makerepo LF | |
|
84 | ||
|
85 | # ==== setup LF repository ==== | |
|
86 | % hg init | |
|
87 | adding .hgeol | |
|
88 | adding native.txt | |
|
89 | adding unix.txt | |
|
90 | adding win.txt | |
|
91 | $ dotest LF | |
|
92 | ||
|
93 | % hg clone repo repo-LF | |
|
94 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
95 | % printrepr.py native.txt | |
|
96 | first | |
|
97 | second | |
|
98 | third | |
|
99 | % printrepr.py unix.txt | |
|
100 | first | |
|
101 | second | |
|
102 | third | |
|
103 | % printrepr.py win.txt | |
|
104 | first\r | |
|
105 | second\r | |
|
106 | third\r | |
|
107 | % hg diff | |
|
108 | diff --git a/native.txt b/native.txt | |
|
109 | --- a/native.txt | |
|
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 | |
|
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 |
General Comments 0
You need to be logged in to leave comments.
Login now