Show More
This diff has been collapsed as it changes many lines, (560 lines changed) Show them Hide them | |||
@@ -1,144 +1,436 b'' | |||
|
1 | #!/bin/sh | |
|
2 | ||
|
3 | hg init t | |
|
4 | cd t | |
|
5 | ||
|
6 | cat > unix2dos.py <<EOF | |
|
7 | import sys | |
|
8 | ||
|
9 | for path in sys.argv[1:]: | |
|
10 | data = file(path, 'rb').read() | |
|
11 | data = data.replace('\n', '\r\n') | |
|
12 | file(path, 'wb').write(data) | |
|
13 | EOF | |
|
14 | 1 | |
|
15 | cat > print.py <<EOF | |
|
16 | import sys | |
|
17 | print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>')) | |
|
18 | EOF | |
|
2 | $ hg init t | |
|
3 | $ cd t | |
|
4 | $ cat > unix2dos.py <<EOF | |
|
5 | > import sys | |
|
6 | > | |
|
7 | > for path in sys.argv[1:]: | |
|
8 | > data = file(path, 'rb').read() | |
|
9 | > data = data.replace('\n', '\r\n') | |
|
10 | > file(path, 'wb').write(data) | |
|
11 | > EOF | |
|
12 | $ cat > print.py <<EOF | |
|
13 | > import sys | |
|
14 | > print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>')) | |
|
15 | > EOF | |
|
16 | $ echo '[hooks]' >> .hg/hgrc | |
|
17 | $ echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc | |
|
18 | $ echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc | |
|
19 | $ cat .hg/hgrc | |
|
20 | [hooks] | |
|
21 | pretxncommit.crlf = python:hgext.win32text.forbidcrlf | |
|
22 | pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf | |
|
23 | $ echo | |
|
24 | ||
|
25 | $ echo hello > f | |
|
26 | $ hg add f | |
|
19 | 27 | |
|
20 | echo '[hooks]' >> .hg/hgrc | |
|
21 | echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc | |
|
22 | echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc | |
|
23 | cat .hg/hgrc | |
|
24 | echo | |
|
28 | commit should succeed | |
|
29 | ||
|
30 | $ hg ci -m 1 | |
|
31 | $ echo | |
|
32 | ||
|
33 | $ hg clone . ../zoz | |
|
34 | updating to branch default | |
|
35 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
36 | $ cp .hg/hgrc ../zoz/.hg | |
|
37 | $ python unix2dos.py f | |
|
38 | ||
|
39 | commit should fail | |
|
25 | 40 | |
|
26 | echo hello > f | |
|
27 | hg add f | |
|
28 | echo commit should succeed | |
|
29 | hg ci -m 1 | |
|
30 | echo | |
|
41 | $ hg ci -m 2.1 | |
|
42 | Attempt to commit or push text file(s) using CRLF line endings | |
|
43 | in f583ea08d42a: f | |
|
44 | transaction abort! | |
|
45 | rollback completed | |
|
46 | abort: pretxncommit.crlf hook failed | |
|
47 | [255] | |
|
48 | $ echo | |
|
49 | ||
|
50 | $ mv .hg/hgrc .hg/hgrc.bak | |
|
31 | 51 | |
|
32 | hg clone . ../zoz | |
|
33 | cp .hg/hgrc ../zoz/.hg | |
|
52 | commits should succeed | |
|
34 | 53 | |
|
35 | python unix2dos.py f | |
|
36 | echo commit should fail | |
|
37 |
hg ci -m 2. |
|
|
38 | echo | |
|
54 | $ hg ci -m 2 | |
|
55 | $ hg cp f g | |
|
56 | $ hg ci -m 2.2 | |
|
57 | $ echo | |
|
58 | ||
|
39 | 59 | |
|
40 | mv .hg/hgrc .hg/hgrc.bak | |
|
41 | echo commits should succeed | |
|
42 | hg ci -m 2 | |
|
43 | hg cp f g | |
|
44 | hg ci -m 2.2 | |
|
45 | echo | |
|
46 | ||
|
47 | echo push should fail | |
|
48 | hg push ../zoz | |
|
49 | echo | |
|
60 | push should fail | |
|
50 | 61 | |
|
51 | mv .hg/hgrc.bak .hg/hgrc | |
|
52 | echo hello > f | |
|
53 | hg rm g | |
|
54 | echo commit should succeed | |
|
55 | hg ci -m 2.3 | |
|
56 | echo | |
|
62 | $ hg push ../zoz | |
|
63 | pushing to ../zoz | |
|
64 | searching for changes | |
|
65 | adding changesets | |
|
66 | adding manifests | |
|
67 | adding file changes | |
|
68 | added 2 changesets with 2 changes to 2 files | |
|
69 | Attempt to commit or push text file(s) using CRLF line endings | |
|
70 | in bc2d09796734: g | |
|
71 | in b1aa5cde7ff4: f | |
|
72 | ||
|
73 | To prevent this mistake in your local repository, | |
|
74 | add to Mercurial.ini or .hg/hgrc: | |
|
75 | ||
|
76 | [hooks] | |
|
77 | pretxncommit.crlf = python:hgext.win32text.forbidcrlf | |
|
78 | ||
|
79 | and also consider adding: | |
|
80 | ||
|
81 | [extensions] | |
|
82 | win32text = | |
|
83 | [encode] | |
|
84 | ** = cleverencode: | |
|
85 | [decode] | |
|
86 | ** = cleverdecode: | |
|
87 | transaction abort! | |
|
88 | rollback completed | |
|
89 | abort: pretxnchangegroup.crlf hook failed | |
|
90 | [255] | |
|
91 | $ echo | |
|
92 | ||
|
93 | $ mv .hg/hgrc.bak .hg/hgrc | |
|
94 | $ echo hello > f | |
|
95 | $ hg rm g | |
|
57 | 96 | |
|
58 |
|
|
|
59 | hg push ../zoz | |
|
60 | echo | |
|
97 | commit should succeed | |
|
98 | ||
|
99 | $ hg ci -m 2.3 | |
|
100 | $ echo | |
|
101 | ||
|
102 | ||
|
103 | push should succeed | |
|
61 | 104 | |
|
62 | echo and now for something completely different | |
|
63 | mkdir d | |
|
64 | echo hello > d/f2 | |
|
65 | python unix2dos.py d/f2 | |
|
66 | hg add d/f2 | |
|
67 | hg ci -m 3 | |
|
68 | hg revert -a | |
|
69 | rm d/f2 | |
|
70 | echo | |
|
105 | $ hg push ../zoz | |
|
106 | pushing to ../zoz | |
|
107 | searching for changes | |
|
108 | adding changesets | |
|
109 | adding manifests | |
|
110 | adding file changes | |
|
111 | added 3 changesets with 3 changes to 2 files | |
|
112 | $ echo | |
|
113 | ||
|
114 | ||
|
115 | and now for something completely different | |
|
71 | 116 | |
|
72 | hg rem f | |
|
73 | hg ci -m 4 | |
|
74 | echo | |
|
75 | ||
|
76 | python -c 'file("bin", "wb").write("hello\x00\x0D\x0A")' | |
|
77 | hg add bin | |
|
78 | hg ci -m 5 | |
|
79 | hg log -v | |
|
80 | echo | |
|
81 | ||
|
82 | hg clone . dupe | |
|
83 | echo | |
|
84 | for x in a b c d; do echo content > dupe/$x; done | |
|
85 | hg -R dupe add | |
|
86 | python unix2dos.py dupe/b dupe/c dupe/d | |
|
87 | hg -R dupe ci -m a dupe/a | |
|
88 | hg -R dupe ci -m b/c dupe/[bc] | |
|
89 | hg -R dupe ci -m d dupe/d | |
|
90 | hg -R dupe log -v | |
|
91 | echo | |
|
92 | ||
|
93 | hg pull dupe | |
|
94 | echo | |
|
95 | ||
|
96 | hg log -v | |
|
97 | echo | |
|
98 | ||
|
99 | rm .hg/hgrc | |
|
100 | (echo some; echo text) > f3 | |
|
101 | python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")' | |
|
102 | hg add f3 f4.bat | |
|
103 | hg ci -m 6 | |
|
104 | ||
|
105 | python print.py < bin | |
|
106 | python print.py < f3 | |
|
107 | python print.py < f4.bat | |
|
108 | echo | |
|
109 | ||
|
110 | echo '[extensions]' >> .hg/hgrc | |
|
111 | echo 'win32text = ' >> .hg/hgrc | |
|
112 | echo '[decode]' >> .hg/hgrc | |
|
113 | echo '** = cleverdecode:' >> .hg/hgrc | |
|
114 | echo '[encode]' >> .hg/hgrc | |
|
115 | echo '** = cleverencode:' >> .hg/hgrc | |
|
116 | cat .hg/hgrc | |
|
117 | echo | |
|
118 | ||
|
119 | rm f3 f4.bat bin | |
|
120 | hg co -C 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))' | |
|
121 | python print.py < bin | |
|
122 | python print.py < f3 | |
|
123 | python print.py < f4.bat | |
|
124 | echo | |
|
125 | ||
|
126 | python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")' | |
|
127 | hg add f5.sh | |
|
128 | hg ci -m 7 | |
|
129 | python print.py < f5.sh | |
|
130 | hg cat f5.sh | python print.py | |
|
131 | ||
|
132 | echo '% just linefeed' > linefeed | |
|
133 | hg ci -qAm 8 linefeed | |
|
134 | python print.py < linefeed | |
|
135 | hg cat linefeed | python print.py | |
|
136 | hg st -q | |
|
137 | hg revert -a linefeed | |
|
138 | python print.py < linefeed | |
|
139 | hg st -q | |
|
140 | echo modified >> linefeed | |
|
141 | hg st -q | |
|
142 | hg revert -a | |
|
143 | hg st -q | |
|
144 | python print.py < linefeed | |
|
117 | $ mkdir d | |
|
118 | $ echo hello > d/f2 | |
|
119 | $ python unix2dos.py d/f2 | |
|
120 | $ hg add d/f2 | |
|
121 | $ hg ci -m 3 | |
|
122 | Attempt to commit or push text file(s) using CRLF line endings | |
|
123 | in 053ba1a3035a: d/f2 | |
|
124 | transaction abort! | |
|
125 | rollback completed | |
|
126 | abort: pretxncommit.crlf hook failed | |
|
127 | [255] | |
|
128 | $ hg revert -a | |
|
129 | forgetting d/f2 | |
|
130 | $ rm d/f2 | |
|
131 | $ echo | |
|
132 | ||
|
133 | $ hg rem f | |
|
134 | $ hg ci -m 4 | |
|
135 | $ echo | |
|
136 | ||
|
137 | $ python -c 'file("bin", "wb").write("hello\x00\x0D\x0A")' | |
|
138 | $ hg add bin | |
|
139 | $ hg ci -m 5 | |
|
140 | $ hg log -v | |
|
141 | changeset: 5:f0b1c8d75fce | |
|
142 | tag: tip | |
|
143 | user: test | |
|
144 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
145 | files: bin | |
|
146 | description: | |
|
147 | 5 | |
|
148 | ||
|
149 | ||
|
150 | changeset: 4:77796dbcd4ad | |
|
151 | user: test | |
|
152 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
153 | files: f | |
|
154 | description: | |
|
155 | 4 | |
|
156 | ||
|
157 | ||
|
158 | changeset: 3:7c1b5430b350 | |
|
159 | user: test | |
|
160 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
161 | files: f g | |
|
162 | description: | |
|
163 | 2.3 | |
|
164 | ||
|
165 | ||
|
166 | changeset: 2:bc2d09796734 | |
|
167 | user: test | |
|
168 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
169 | files: g | |
|
170 | description: | |
|
171 | 2.2 | |
|
172 | ||
|
173 | ||
|
174 | changeset: 1:b1aa5cde7ff4 | |
|
175 | user: test | |
|
176 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
177 | files: f | |
|
178 | description: | |
|
179 | 2 | |
|
180 | ||
|
181 | ||
|
182 | changeset: 0:fcf06d5c4e1d | |
|
183 | user: test | |
|
184 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
185 | files: f | |
|
186 | description: | |
|
187 | 1 | |
|
188 | ||
|
189 | ||
|
190 | $ echo | |
|
191 | ||
|
192 | $ hg clone . dupe | |
|
193 | updating to branch default | |
|
194 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
195 | $ echo | |
|
196 | ||
|
197 | $ for x in a b c d; do echo content > dupe/$x; done | |
|
198 | $ hg -R dupe add | |
|
199 | adding dupe/a | |
|
200 | adding dupe/b | |
|
201 | adding dupe/c | |
|
202 | adding dupe/d | |
|
203 | $ python unix2dos.py dupe/b dupe/c dupe/d | |
|
204 | $ hg -R dupe ci -m a dupe/a | |
|
205 | $ hg -R dupe ci -m b/c dupe/[bc] | |
|
206 | $ hg -R dupe ci -m d dupe/d | |
|
207 | $ hg -R dupe log -v | |
|
208 | changeset: 8:67ac5962ab43 | |
|
209 | tag: tip | |
|
210 | user: test | |
|
211 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
212 | files: d | |
|
213 | description: | |
|
214 | d | |
|
215 | ||
|
216 | ||
|
217 | changeset: 7:68c127d1834e | |
|
218 | user: test | |
|
219 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
220 | files: b c | |
|
221 | description: | |
|
222 | b/c | |
|
223 | ||
|
224 | ||
|
225 | changeset: 6:adbf8bf7f31d | |
|
226 | user: test | |
|
227 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
228 | files: a | |
|
229 | description: | |
|
230 | a | |
|
231 | ||
|
232 | ||
|
233 | changeset: 5:f0b1c8d75fce | |
|
234 | user: test | |
|
235 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
236 | files: bin | |
|
237 | description: | |
|
238 | 5 | |
|
239 | ||
|
240 | ||
|
241 | changeset: 4:77796dbcd4ad | |
|
242 | user: test | |
|
243 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
244 | files: f | |
|
245 | description: | |
|
246 | 4 | |
|
247 | ||
|
248 | ||
|
249 | changeset: 3:7c1b5430b350 | |
|
250 | user: test | |
|
251 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
252 | files: f g | |
|
253 | description: | |
|
254 | 2.3 | |
|
255 | ||
|
256 | ||
|
257 | changeset: 2:bc2d09796734 | |
|
258 | user: test | |
|
259 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
260 | files: g | |
|
261 | description: | |
|
262 | 2.2 | |
|
263 | ||
|
264 | ||
|
265 | changeset: 1:b1aa5cde7ff4 | |
|
266 | user: test | |
|
267 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
268 | files: f | |
|
269 | description: | |
|
270 | 2 | |
|
271 | ||
|
272 | ||
|
273 | changeset: 0:fcf06d5c4e1d | |
|
274 | user: test | |
|
275 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
276 | files: f | |
|
277 | description: | |
|
278 | 1 | |
|
279 | ||
|
280 | ||
|
281 | $ echo | |
|
282 | ||
|
283 | $ hg pull dupe | |
|
284 | pulling from dupe | |
|
285 | searching for changes | |
|
286 | adding changesets | |
|
287 | adding manifests | |
|
288 | adding file changes | |
|
289 | added 3 changesets with 4 changes to 4 files | |
|
290 | Attempt to commit or push text file(s) using CRLF line endings | |
|
291 | in 67ac5962ab43: d | |
|
292 | in 68c127d1834e: b | |
|
293 | in 68c127d1834e: c | |
|
294 | ||
|
295 | To prevent this mistake in your local repository, | |
|
296 | add to Mercurial.ini or .hg/hgrc: | |
|
297 | ||
|
298 | [hooks] | |
|
299 | pretxncommit.crlf = python:hgext.win32text.forbidcrlf | |
|
300 | ||
|
301 | and also consider adding: | |
|
302 | ||
|
303 | [extensions] | |
|
304 | win32text = | |
|
305 | [encode] | |
|
306 | ** = cleverencode: | |
|
307 | [decode] | |
|
308 | ** = cleverdecode: | |
|
309 | transaction abort! | |
|
310 | rollback completed | |
|
311 | abort: pretxnchangegroup.crlf hook failed | |
|
312 | [255] | |
|
313 | $ echo | |
|
314 | ||
|
315 | $ hg log -v | |
|
316 | changeset: 5:f0b1c8d75fce | |
|
317 | tag: tip | |
|
318 | user: test | |
|
319 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
320 | files: bin | |
|
321 | description: | |
|
322 | 5 | |
|
323 | ||
|
324 | ||
|
325 | changeset: 4:77796dbcd4ad | |
|
326 | user: test | |
|
327 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
328 | files: f | |
|
329 | description: | |
|
330 | 4 | |
|
331 | ||
|
332 | ||
|
333 | changeset: 3:7c1b5430b350 | |
|
334 | user: test | |
|
335 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
336 | files: f g | |
|
337 | description: | |
|
338 | 2.3 | |
|
339 | ||
|
340 | ||
|
341 | changeset: 2:bc2d09796734 | |
|
342 | user: test | |
|
343 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
344 | files: g | |
|
345 | description: | |
|
346 | 2.2 | |
|
347 | ||
|
348 | ||
|
349 | changeset: 1:b1aa5cde7ff4 | |
|
350 | user: test | |
|
351 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
352 | files: f | |
|
353 | description: | |
|
354 | 2 | |
|
355 | ||
|
356 | ||
|
357 | changeset: 0:fcf06d5c4e1d | |
|
358 | user: test | |
|
359 | date: Thu Jan 01 00:00:00 1970 +0000 | |
|
360 | files: f | |
|
361 | description: | |
|
362 | 1 | |
|
363 | ||
|
364 | ||
|
365 | $ echo | |
|
366 | ||
|
367 | $ rm .hg/hgrc | |
|
368 | $ (echo some; echo text) > f3 | |
|
369 | $ python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")' | |
|
370 | $ hg add f3 f4.bat | |
|
371 | $ hg ci -m 6 | |
|
372 | $ python print.py < bin | |
|
373 | hello<NUL><CR><LF> | |
|
374 | $ python print.py < f3 | |
|
375 | some<LF>text<LF> | |
|
376 | $ python print.py < f4.bat | |
|
377 | rem empty<CR><LF> | |
|
378 | $ echo | |
|
379 | ||
|
380 | $ echo '[extensions]' >> .hg/hgrc | |
|
381 | $ echo 'win32text = ' >> .hg/hgrc | |
|
382 | $ echo '[decode]' >> .hg/hgrc | |
|
383 | $ echo '** = cleverdecode:' >> .hg/hgrc | |
|
384 | $ echo '[encode]' >> .hg/hgrc | |
|
385 | $ echo '** = cleverencode:' >> .hg/hgrc | |
|
386 | $ cat .hg/hgrc | |
|
387 | [extensions] | |
|
388 | win32text = | |
|
389 | [decode] | |
|
390 | ** = cleverdecode: | |
|
391 | [encode] | |
|
392 | ** = cleverencode: | |
|
393 | $ echo | |
|
394 | ||
|
395 | $ rm f3 f4.bat bin | |
|
396 | $ hg co -C 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))' | |
|
397 | WARNING: f4.bat already has CRLF line endings | |
|
398 | and does not need EOL conversion by the win32text plugin. | |
|
399 | Before your next commit, please reconsider your encode/decode settings in | |
|
400 | Mercurial.ini or ..../.hg/hgrc. | |
|
401 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
402 | $ python print.py < bin | |
|
403 | hello<NUL><CR><LF> | |
|
404 | $ python print.py < f3 | |
|
405 | some<CR><LF>text<CR><LF> | |
|
406 | $ python print.py < f4.bat | |
|
407 | rem empty<CR><LF> | |
|
408 | $ echo | |
|
409 | ||
|
410 | $ python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")' | |
|
411 | $ hg add f5.sh | |
|
412 | $ hg ci -m 7 | |
|
413 | $ python print.py < f5.sh | |
|
414 | # empty<CR><LF> | |
|
415 | $ hg cat f5.sh | python print.py | |
|
416 | # empty<LF> | |
|
417 | $ echo '% just linefeed' > linefeed | |
|
418 | $ hg ci -qAm 8 linefeed | |
|
419 | $ python print.py < linefeed | |
|
420 | % just linefeed<LF> | |
|
421 | $ hg cat linefeed | python print.py | |
|
422 | % just linefeed<LF> | |
|
423 | $ hg st -q | |
|
424 | $ hg revert -a linefeed | |
|
425 | no changes needed to linefeed | |
|
426 | $ python print.py < linefeed | |
|
427 | % just linefeed<LF> | |
|
428 | $ hg st -q | |
|
429 | $ echo modified >> linefeed | |
|
430 | $ hg st -q | |
|
431 | M linefeed | |
|
432 | $ hg revert -a | |
|
433 | reverting linefeed | |
|
434 | $ hg st -q | |
|
435 | $ python print.py < linefeed | |
|
436 | % just linefeed<CR><LF> |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now