author | Thomas Arendsen Hein <thomas@intevation.de> |
Fri, 07 Mar 2008 00:24:36 +0100 | |
changeset 6210 | 942287cb1f57 |
parent 5967 | f8ad3b76e923 |
child 6299 | 653ddd1d7cd7 |
permissions | -rwxr-xr-x |
5675
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
1 |
#!/bin/sh |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
2 |
|
6210
942287cb1f57
Removed trailing spaces from everything except test output
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5967
diff
changeset
|
3 |
cat > unix2dos.py <<EOF |
5680
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
4 |
import sys |
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
5 |
|
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
6 |
for path in sys.argv[1:]: |
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
7 |
data = file(path, 'rb').read() |
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
8 |
data = data.replace('\n', '\r\n') |
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
9 |
file(path, 'wb').write(data) |
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
10 |
EOF |
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
11 |
|
5967
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
12 |
cat > print.py <<EOF |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
13 |
import sys |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
14 |
print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>')) |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
15 |
EOF |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
16 |
|
5675
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
17 |
hg init |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
18 |
echo '[hooks]' >> .hg/hgrc |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
19 |
echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
20 |
echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
21 |
cat .hg/hgrc |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
22 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
23 |
|
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
24 |
echo hello > f |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
25 |
hg add f |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
26 |
hg ci -m 1 -d'0 0' |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
27 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
28 |
|
5680
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
29 |
python unix2dos.py f |
5675
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
30 |
hg ci -m 2 -d'0 0' |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
31 |
hg revert -a |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
32 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
33 |
|
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
34 |
mkdir d |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
35 |
echo hello > d/f2 |
5680
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
36 |
python unix2dos.py d/f2 |
5675
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
37 |
hg add d/f2 |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
38 |
hg ci -m 3 -d'0 0' |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
39 |
hg revert -a |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
40 |
rm d/f2 |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
41 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
42 |
|
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
43 |
hg rem f |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
44 |
hg ci -m 4 -d'0 0' |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
45 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
46 |
|
5680
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
47 |
python -c 'file("bin", "wb").write("hello\x00\x0D\x0A")' |
5675
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
48 |
hg add bin |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
49 |
hg ci -m 5 -d'0 0' |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
50 |
hg log -v |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
51 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
52 |
|
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
53 |
hg clone . dupe |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
54 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
55 |
for x in a b c d; do echo content > dupe/$x; done |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
56 |
hg -R dupe add |
5680
963c516bb38c
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard <pmezard@gmail.com>
parents:
5675
diff
changeset
|
57 |
python unix2dos.py dupe/b dupe/c dupe/d |
5675
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
58 |
hg -R dupe ci -m a -d'0 0' dupe/a |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
59 |
hg -R dupe ci -m b/c -d'0 0' dupe/[bc] |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
60 |
hg -R dupe ci -m d -d'0 0' dupe/d |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
61 |
hg -R dupe log -v |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
62 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
63 |
|
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
64 |
hg pull dupe |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
65 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
66 |
|
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
67 |
hg log -v |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
68 |
echo |
a5fe27b83a4a
Issue 882: add standard hook to reject text files with CRLF.
Jesse Glick <jesse.glick@sun.com>
parents:
diff
changeset
|
69 |
|
5967
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
70 |
rm .hg/hgrc |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
71 |
(echo some; echo text) > f3 |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
72 |
python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")' |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
73 |
hg add f3 f4.bat |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
74 |
hg ci -m 6 -d'0 0' |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
75 |
|
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
76 |
python print.py < bin |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
77 |
python print.py < f3 |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
78 |
python print.py < f4.bat |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
79 |
echo |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
80 |
|
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
81 |
echo '[extensions]' >> .hg/hgrc |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
82 |
echo 'win32text = ' >> .hg/hgrc |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
83 |
echo '[decode]' >> .hg/hgrc |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
84 |
echo '** = cleverdecode:' >> .hg/hgrc |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
85 |
echo '[encode]' >> .hg/hgrc |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
86 |
echo '** = cleverencode:' >> .hg/hgrc |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
87 |
cat .hg/hgrc |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
88 |
echo |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
89 |
|
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
90 |
rm f3 f4.bat bin |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
91 |
hg co 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))' |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
92 |
python print.py < bin |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
93 |
python print.py < f3 |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
94 |
python print.py < f4.bat |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
95 |
echo |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
96 |
|
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
97 |
python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")' |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
98 |
hg add f5.sh |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
99 |
hg ci -m 7 -d'0 0' |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
100 |
python print.py < f5.sh |
f8ad3b76e923
Provide better context for custom Python encode/decode filters.
Jesse Glick <jesse.glick@sun.com>
parents:
5680
diff
changeset
|
101 |
hg cat f5.sh | python print.py |