Mercurial > hg
annotate tests/test-eol.t @ 12684:8348599c68d7
keyword: fix weeding of expansion candidates when recording
Rearrange tests to check this, i.e. that there are changes
in other files, not only the recorded one.
author | Christian Ebert <blacktrash@gmx.net> |
---|---|
date | Sun, 10 Oct 2010 00:30:09 +0100 |
parents | f6a91fcd189a |
children | 7439ea4146f8 |
rev | line source |
---|---|
12419 | 1 Test EOL extension |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
2 |
12419 | 3 $ cat > $HGRCPATH <<EOF |
4 > [diff] | |
5 > git = True | |
6 > EOF | |
7 | |
8 Set up helpers | |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
9 |
12419 | 10 $ cat > switch-eol.py <<EOF |
11 > import sys | |
12 > try: | |
13 > import os, msvcrt | |
14 > msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) | |
15 > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | |
16 > except ImportError: | |
17 > pass | |
18 > (old, new) = sys.argv[1] == 'LF' and ('\n', '\r\n') or ('\r\n', '\n') | |
19 > print "%% switching encoding from %r to %r" % (old, new) | |
20 > for path in sys.argv[2:]: | |
21 > data = file(path, 'rb').read() | |
22 > data = data.replace(old, new) | |
23 > file(path, 'wb').write(data) | |
24 > EOF | |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
25 |
12419 | 26 $ seteol () { |
27 > if [ $1 = "LF" ]; then | |
28 > EOL='\n' | |
29 > else | |
30 > EOL='\r\n' | |
31 > fi | |
32 > } | |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
33 |
12419 | 34 $ makerepo () { |
35 > seteol $1 | |
36 > echo "% setup $1 repository" | |
37 > hg init repo | |
38 > cd repo | |
39 > cat > .hgeol <<EOF | |
40 > [repository] | |
41 > native = $1 | |
42 > [patterns] | |
43 > mixed.txt = BIN | |
44 > **.txt = native | |
45 > EOF | |
46 > printf "first${EOL}second${EOL}third${EOL}" > a.txt | |
47 > hg commit --addremove -m 'checkin' | |
48 > echo | |
49 > cd .. | |
50 > } | |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
51 |
12419 | 52 $ dotest () { |
53 > seteol $1 | |
54 > echo "% hg clone repo repo-$1" | |
55 > hg clone --noupdate repo repo-$1 | |
56 > cd repo-$1 | |
57 > cat > .hg/hgrc <<EOF | |
58 > [extensions] | |
59 > eol = | |
60 > [eol] | |
61 > native = $1 | |
62 > EOF | |
63 > hg update | |
64 > echo '% printrepr.py a.txt' | |
65 > python $TESTDIR/printrepr.py < a.txt | |
66 > echo '% hg cat a.txt' | |
67 > hg cat a.txt | python $TESTDIR/printrepr.py | |
68 > printf "fourth${EOL}" >> a.txt | |
69 > echo '% printrepr.py a.txt' | |
70 > python $TESTDIR/printrepr.py < a.txt | |
71 > hg diff | python $TESTDIR/printrepr.py | |
72 > python ../switch-eol.py $1 a.txt | |
73 > echo '% hg diff only reports a single changed line:' | |
74 > hg diff | python $TESTDIR/printrepr.py | |
75 > echo "% reverting back to $1 format" | |
76 > hg revert a.txt | |
77 > python $TESTDIR/printrepr.py < a.txt | |
78 > printf "first\r\nsecond\n" > mixed.txt | |
79 > hg add mixed.txt | |
80 > echo "% hg commit of inconsistent .txt file marked as binary (should work)" | |
81 > hg commit -m 'binary file' | |
82 > echo "% hg commit of inconsistent .txt file marked as native (should fail)" | |
83 > printf "first\nsecond\r\nthird\nfourth\r\n" > a.txt | |
84 > hg commit -m 'inconsistent file' | |
85 > echo "% hg commit --config eol.only-consistent=False (should work)" | |
86 > hg commit --config eol.only-consistent=False -m 'inconsistent file' | |
87 > echo "% hg commit of binary .txt file marked as native (binary files always okay)" | |
88 > printf "first${EOL}\0${EOL}third${EOL}" > a.txt | |
89 > hg commit -m 'binary file' | |
90 > cd .. | |
91 > rm -r repo-$1 | |
92 > } | |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
93 |
12419 | 94 $ makemixedrepo () { |
95 > echo | |
96 > echo "# setup $1 repository" | |
97 > hg init mixed | |
98 > cd mixed | |
99 > printf "foo\r\nbar\r\nbaz\r\n" > win.txt | |
100 > printf "foo\nbar\nbaz\n" > unix.txt | |
101 > #printf "foo\r\nbar\nbaz\r\n" > mixed.txt | |
102 > hg commit --addremove -m 'created mixed files' | |
103 > echo "# setting repository-native EOLs to $1" | |
104 > cat > .hgeol <<EOF | |
105 > [repository] | |
106 > native = $1 | |
107 > [patterns] | |
108 > **.txt = native | |
109 > EOF | |
110 > hg commit --addremove -m 'added .hgeol' | |
111 > cd .. | |
112 > } | |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
113 |
12419 | 114 $ testmixed () { |
115 > echo | |
116 > echo "% hg clone mixed mixed-$1" | |
117 > hg clone mixed mixed-$1 | |
118 > cd mixed-$1 | |
119 > echo '% hg status (eol extension not yet activated)' | |
120 > hg status | |
121 > cat > .hg/hgrc <<EOF | |
122 > [extensions] | |
123 > eol = | |
124 > [eol] | |
125 > native = $1 | |
126 > EOF | |
127 > echo '% hg status (eol activated)' | |
128 > hg status | |
129 > echo '% hg commit' | |
130 > hg commit -m 'synchronized EOLs' | |
131 > echo '% hg status' | |
132 > hg status | |
133 > cd .. | |
134 > rm -r mixed-$1 | |
135 > } | |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
136 |
12419 | 137 Basic tests |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
138 |
12419 | 139 $ makerepo LF |
140 % setup LF repository | |
141 adding .hgeol | |
142 adding a.txt | |
143 | |
144 $ dotest LF | |
145 % hg clone repo repo-LF | |
146 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
147 % printrepr.py a.txt | |
148 first | |
149 second | |
150 third | |
151 % hg cat a.txt | |
152 first | |
153 second | |
154 third | |
155 % printrepr.py a.txt | |
156 first | |
157 second | |
158 third | |
159 fourth | |
160 diff --git a/a.txt b/a.txt | |
161 --- a/a.txt | |
162 +++ b/a.txt | |
163 @@ -1,3 +1,4 @@ | |
164 first | |
165 second | |
166 third | |
167 +fourth | |
168 % switching encoding from '\n' to '\r\n' | |
169 % hg diff only reports a single changed line: | |
170 diff --git a/a.txt b/a.txt | |
171 --- a/a.txt | |
172 +++ b/a.txt | |
173 @@ -1,3 +1,4 @@ | |
174 first | |
175 second | |
176 third | |
177 +fourth | |
178 % reverting back to LF format | |
179 first | |
180 second | |
181 third | |
182 % hg commit of inconsistent .txt file marked as binary (should work) | |
183 % hg commit of inconsistent .txt file marked as native (should fail) | |
184 abort: inconsistent newline style in a.txt | |
185 | |
186 % hg commit --config eol.only-consistent=False (should work) | |
187 % hg commit of binary .txt file marked as native (binary files always okay) | |
188 $ dotest CRLF | |
189 % hg clone repo repo-CRLF | |
190 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
191 % printrepr.py a.txt | |
192 first\r | |
193 second\r | |
194 third\r | |
195 % hg cat a.txt | |
196 first | |
197 second | |
198 third | |
199 % printrepr.py a.txt | |
200 first\r | |
201 second\r | |
202 third\r | |
203 fourth\r | |
204 diff --git a/a.txt b/a.txt | |
205 --- a/a.txt | |
206 +++ b/a.txt | |
207 @@ -1,3 +1,4 @@ | |
208 first | |
209 second | |
210 third | |
211 +fourth | |
212 % switching encoding from '\r\n' to '\n' | |
213 % hg diff only reports a single changed line: | |
214 diff --git a/a.txt b/a.txt | |
215 --- a/a.txt | |
216 +++ b/a.txt | |
217 @@ -1,3 +1,4 @@ | |
218 first | |
219 second | |
220 third | |
221 +fourth | |
222 % reverting back to CRLF format | |
223 first\r | |
224 second\r | |
225 third\r | |
226 % hg commit of inconsistent .txt file marked as binary (should work) | |
227 % hg commit of inconsistent .txt file marked as native (should fail) | |
228 abort: inconsistent newline style in a.txt | |
229 | |
230 % hg commit --config eol.only-consistent=False (should work) | |
231 % hg commit of binary .txt file marked as native (binary files always okay) | |
232 $ rm -r repo | |
233 $ makerepo CRLF | |
234 % setup CRLF repository | |
235 adding .hgeol | |
236 adding a.txt | |
237 | |
238 $ dotest LF | |
239 % hg clone repo repo-LF | |
240 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
241 % printrepr.py a.txt | |
242 first | |
243 second | |
244 third | |
245 % hg cat a.txt | |
246 first\r | |
247 second\r | |
248 third\r | |
249 % printrepr.py a.txt | |
250 first | |
251 second | |
252 third | |
253 fourth | |
254 diff --git a/a.txt b/a.txt | |
255 --- a/a.txt | |
256 +++ b/a.txt | |
257 @@ -1,3 +1,4 @@ | |
258 first\r | |
259 second\r | |
260 third\r | |
261 +fourth\r | |
262 % switching encoding from '\n' to '\r\n' | |
263 % hg diff only reports a single changed line: | |
264 diff --git a/a.txt b/a.txt | |
265 --- a/a.txt | |
266 +++ b/a.txt | |
267 @@ -1,3 +1,4 @@ | |
268 first\r | |
269 second\r | |
270 third\r | |
271 +fourth\r | |
272 % reverting back to LF format | |
273 first | |
274 second | |
275 third | |
276 % hg commit of inconsistent .txt file marked as binary (should work) | |
277 % hg commit of inconsistent .txt file marked as native (should fail) | |
278 abort: inconsistent newline style in a.txt | |
279 | |
280 % hg commit --config eol.only-consistent=False (should work) | |
281 % hg commit of binary .txt file marked as native (binary files always okay) | |
282 $ dotest CRLF | |
283 % hg clone repo repo-CRLF | |
284 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
285 % printrepr.py a.txt | |
286 first\r | |
287 second\r | |
288 third\r | |
289 % hg cat a.txt | |
290 first\r | |
291 second\r | |
292 third\r | |
293 % printrepr.py a.txt | |
294 first\r | |
295 second\r | |
296 third\r | |
297 fourth\r | |
298 diff --git a/a.txt b/a.txt | |
299 --- a/a.txt | |
300 +++ b/a.txt | |
301 @@ -1,3 +1,4 @@ | |
302 first\r | |
303 second\r | |
304 third\r | |
305 +fourth\r | |
306 % switching encoding from '\r\n' to '\n' | |
307 % hg diff only reports a single changed line: | |
308 diff --git a/a.txt b/a.txt | |
309 --- a/a.txt | |
310 +++ b/a.txt | |
311 @@ -1,3 +1,4 @@ | |
312 first\r | |
313 second\r | |
314 third\r | |
315 +fourth\r | |
316 % reverting back to CRLF format | |
317 first\r | |
318 second\r | |
319 third\r | |
320 % hg commit of inconsistent .txt file marked as binary (should work) | |
321 % hg commit of inconsistent .txt file marked as native (should fail) | |
322 abort: inconsistent newline style in a.txt | |
323 | |
324 % hg commit --config eol.only-consistent=False (should work) | |
325 % hg commit of binary .txt file marked as native (binary files always okay) | |
326 $ rm -r repo | |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
327 |
12419 | 328 Mixed tests |
11249
0bb67503ad4b
eol: extension for managing file EOLs
Martin Geisler <mg@lazybytes.net>
parents:
diff
changeset
|
329 |
12419 | 330 $ makemixedrepo LF |
331 | |
332 # setup LF repository | |
333 adding unix.txt | |
334 adding win.txt | |
335 # setting repository-native EOLs to LF | |
336 adding .hgeol | |
337 $ testmixed LF | |
338 | |
339 % hg clone mixed mixed-LF | |
340 updating to branch default | |
341 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
342 % hg status (eol extension not yet activated) | |
343 % hg status (eol activated) | |
344 M win.txt | |
345 % hg commit | |
346 % hg status | |
347 $ testmixed CRLF | |
348 | |
349 % hg clone mixed mixed-CRLF | |
350 updating to branch default | |
351 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
352 % hg status (eol extension not yet activated) | |
353 % hg status (eol activated) | |
354 M win.txt | |
355 % hg commit | |
356 % hg status | |
357 $ rm -r mixed | |
358 $ makemixedrepo CRLF | |
359 | |
360 # setup CRLF repository | |
361 adding unix.txt | |
362 adding win.txt | |
363 # setting repository-native EOLs to CRLF | |
364 adding .hgeol | |
365 $ testmixed LF | |
366 | |
367 % hg clone mixed mixed-LF | |
368 updating to branch default | |
369 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
370 % hg status (eol extension not yet activated) | |
371 % hg status (eol activated) | |
372 M unix.txt | |
373 % hg commit | |
374 % hg status | |
375 $ testmixed CRLF | |
376 | |
377 % hg clone mixed mixed-CRLF | |
378 updating to branch default | |
379 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
380 % hg status (eol extension not yet activated) | |
381 % hg status (eol activated) | |
382 M unix.txt | |
383 % hg commit | |
384 % hg status | |
385 $ rm -r mixed |