##// END OF EJS Templates
test-win32text: avoid unix2dos, printf extensions
Patrick Mezard -
r5680:963c516b default
parent child Browse files
Show More
@@ -1,56 +1,65
1 #!/bin/sh
1 #!/bin/sh
2
2
3 cat > unix2dos.py <<EOF
4 import sys
5
6 for path in sys.argv[1:]:
7 data = file(path, 'rb').read()
8 data = data.replace('\n', '\r\n')
9 file(path, 'wb').write(data)
10 EOF
11
3 hg init
12 hg init
4 echo '[hooks]' >> .hg/hgrc
13 echo '[hooks]' >> .hg/hgrc
5 echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
14 echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
6 echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
15 echo 'pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
7 cat .hg/hgrc
16 cat .hg/hgrc
8 echo
17 echo
9
18
10 echo hello > f
19 echo hello > f
11 hg add f
20 hg add f
12 hg ci -m 1 -d'0 0'
21 hg ci -m 1 -d'0 0'
13 echo
22 echo
14
23
15 unix2dos f
24 python unix2dos.py f
16 hg ci -m 2 -d'0 0'
25 hg ci -m 2 -d'0 0'
17 hg revert -a
26 hg revert -a
18 echo
27 echo
19
28
20 mkdir d
29 mkdir d
21 echo hello > d/f2
30 echo hello > d/f2
22 unix2dos d/f2
31 python unix2dos.py d/f2
23 hg add d/f2
32 hg add d/f2
24 hg ci -m 3 -d'0 0'
33 hg ci -m 3 -d'0 0'
25 hg revert -a
34 hg revert -a
26 rm d/f2
35 rm d/f2
27 echo
36 echo
28
37
29 hg rem f
38 hg rem f
30 hg ci -m 4 -d'0 0'
39 hg ci -m 4 -d'0 0'
31 echo
40 echo
32
41
33 printf 'hello\x00\x0D\x0A' > bin
42 python -c 'file("bin", "wb").write("hello\x00\x0D\x0A")'
34 hg add bin
43 hg add bin
35 hg ci -m 5 -d'0 0'
44 hg ci -m 5 -d'0 0'
36 hg log -v
45 hg log -v
37 echo
46 echo
38
47
39 hg clone . dupe
48 hg clone . dupe
40 echo
49 echo
41 for x in a b c d; do echo content > dupe/$x; done
50 for x in a b c d; do echo content > dupe/$x; done
42 hg -R dupe add
51 hg -R dupe add
43 unix2dos dupe/b dupe/c dupe/d
52 python unix2dos.py dupe/b dupe/c dupe/d
44 hg -R dupe ci -m a -d'0 0' dupe/a
53 hg -R dupe ci -m a -d'0 0' dupe/a
45 hg -R dupe ci -m b/c -d'0 0' dupe/[bc]
54 hg -R dupe ci -m b/c -d'0 0' dupe/[bc]
46 hg -R dupe ci -m d -d'0 0' dupe/d
55 hg -R dupe ci -m d -d'0 0' dupe/d
47 hg -R dupe log -v
56 hg -R dupe log -v
48 echo
57 echo
49
58
50 hg pull dupe
59 hg pull dupe
51 echo
60 echo
52
61
53 hg log -v
62 hg log -v
54 echo
63 echo
55
64
56 # XXX missing tests for encode/decode hooks
65 # XXX missing tests for encode/decode hooks
@@ -1,157 +1,157
1 [hooks]
1 [hooks]
2 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
2 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
3 pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
3 pretxnchangegroup.crlf = python:hgext.win32text.forbidcrlf
4
4
5
5
6 Attempt to commit or push text file(s) using CRLF line endings
6 Attempt to commit or push text file(s) using CRLF line endings
7 in b1aa5cde7ff4: f
7 in b1aa5cde7ff4: f
8 transaction abort!
8 transaction abort!
9 rollback completed
9 rollback completed
10 abort: pretxncommit.crlf hook failed
10 abort: pretxncommit.crlf hook failed
11 reverting f
11 reverting f
12
12
13 Attempt to commit or push text file(s) using CRLF line endings
13 Attempt to commit or push text file(s) using CRLF line endings
14 in 88b17af74937: d/f2
14 in 88b17af74937: d/f2
15 transaction abort!
15 transaction abort!
16 rollback completed
16 rollback completed
17 abort: pretxncommit.crlf hook failed
17 abort: pretxncommit.crlf hook failed
18 forgetting d/f2
18 forgetting d/f2
19
19
20
20
21 changeset: 2:a55cab36df04
21 changeset: 2:b67b2dae057a
22 tag: tip
22 tag: tip
23 user: test
23 user: test
24 date: Thu Jan 01 00:00:00 1970 +0000
24 date: Thu Jan 01 00:00:00 1970 +0000
25 files: bin
25 files: bin
26 description:
26 description:
27 5
27 5
28
28
29
29
30 changeset: 1:c72a7d1d0907
30 changeset: 1:c72a7d1d0907
31 user: test
31 user: test
32 date: Thu Jan 01 00:00:00 1970 +0000
32 date: Thu Jan 01 00:00:00 1970 +0000
33 files: f
33 files: f
34 description:
34 description:
35 4
35 4
36
36
37
37
38 changeset: 0:fcf06d5c4e1d
38 changeset: 0:fcf06d5c4e1d
39 user: test
39 user: test
40 date: Thu Jan 01 00:00:00 1970 +0000
40 date: Thu Jan 01 00:00:00 1970 +0000
41 files: f
41 files: f
42 description:
42 description:
43 1
43 1
44
44
45
45
46
46
47 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
47 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
48
48
49 adding dupe/a
49 adding dupe/a
50 adding dupe/b
50 adding dupe/b
51 adding dupe/c
51 adding dupe/c
52 adding dupe/d
52 adding dupe/d
53 changeset: 5:81c49ee61396
53 changeset: 5:6e8a7629ff5b
54 tag: tip
54 tag: tip
55 user: test
55 user: test
56 date: Thu Jan 01 00:00:00 1970 +0000
56 date: Thu Jan 01 00:00:00 1970 +0000
57 files: d
57 files: d
58 description:
58 description:
59 d
59 d
60
60
61
61
62 changeset: 4:02184785bcac
62 changeset: 4:ac30a42ce8bc
63 user: test
63 user: test
64 date: Thu Jan 01 00:00:00 1970 +0000
64 date: Thu Jan 01 00:00:00 1970 +0000
65 files: b c
65 files: b c
66 description:
66 description:
67 b/c
67 b/c
68
68
69
69
70 changeset: 3:36e70ffe2c3d
70 changeset: 3:a73b85ef1fb7
71 user: test
71 user: test
72 date: Thu Jan 01 00:00:00 1970 +0000
72 date: Thu Jan 01 00:00:00 1970 +0000
73 files: a
73 files: a
74 description:
74 description:
75 a
75 a
76
76
77
77
78 changeset: 2:a55cab36df04
78 changeset: 2:b67b2dae057a
79 user: test
79 user: test
80 date: Thu Jan 01 00:00:00 1970 +0000
80 date: Thu Jan 01 00:00:00 1970 +0000
81 files: bin
81 files: bin
82 description:
82 description:
83 5
83 5
84
84
85
85
86 changeset: 1:c72a7d1d0907
86 changeset: 1:c72a7d1d0907
87 user: test
87 user: test
88 date: Thu Jan 01 00:00:00 1970 +0000
88 date: Thu Jan 01 00:00:00 1970 +0000
89 files: f
89 files: f
90 description:
90 description:
91 4
91 4
92
92
93
93
94 changeset: 0:fcf06d5c4e1d
94 changeset: 0:fcf06d5c4e1d
95 user: test
95 user: test
96 date: Thu Jan 01 00:00:00 1970 +0000
96 date: Thu Jan 01 00:00:00 1970 +0000
97 files: f
97 files: f
98 description:
98 description:
99 1
99 1
100
100
101
101
102
102
103 pulling from dupe
103 pulling from dupe
104 searching for changes
104 searching for changes
105 adding changesets
105 adding changesets
106 adding manifests
106 adding manifests
107 adding file changes
107 adding file changes
108 added 3 changesets with 4 changes to 4 files
108 added 3 changesets with 4 changes to 4 files
109 Attempt to commit or push text file(s) using CRLF line endings
109 Attempt to commit or push text file(s) using CRLF line endings
110 in 02184785bcac: b
110 in ac30a42ce8bc: b
111 in 02184785bcac: c
111 in ac30a42ce8bc: c
112 in 81c49ee61396: d
112 in 6e8a7629ff5b: d
113
113
114 To prevent this mistake in your local repository,
114 To prevent this mistake in your local repository,
115 add to Mercurial.ini or .hg/hgrc:
115 add to Mercurial.ini or .hg/hgrc:
116
116
117 [hooks]
117 [hooks]
118 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
118 pretxncommit.crlf = python:hgext.win32text.forbidcrlf
119
119
120 and also consider adding:
120 and also consider adding:
121
121
122 [extensions]
122 [extensions]
123 hgext.win32text =
123 hgext.win32text =
124 [encode]
124 [encode]
125 ** = cleverencode:
125 ** = cleverencode:
126 [decode]
126 [decode]
127 ** = cleverdecode:
127 ** = cleverdecode:
128 transaction abort!
128 transaction abort!
129 rollback completed
129 rollback completed
130 abort: pretxnchangegroup.crlf hook failed
130 abort: pretxnchangegroup.crlf hook failed
131
131
132 changeset: 2:a55cab36df04
132 changeset: 2:b67b2dae057a
133 tag: tip
133 tag: tip
134 user: test
134 user: test
135 date: Thu Jan 01 00:00:00 1970 +0000
135 date: Thu Jan 01 00:00:00 1970 +0000
136 files: bin
136 files: bin
137 description:
137 description:
138 5
138 5
139
139
140
140
141 changeset: 1:c72a7d1d0907
141 changeset: 1:c72a7d1d0907
142 user: test
142 user: test
143 date: Thu Jan 01 00:00:00 1970 +0000
143 date: Thu Jan 01 00:00:00 1970 +0000
144 files: f
144 files: f
145 description:
145 description:
146 4
146 4
147
147
148
148
149 changeset: 0:fcf06d5c4e1d
149 changeset: 0:fcf06d5c4e1d
150 user: test
150 user: test
151 date: Thu Jan 01 00:00:00 1970 +0000
151 date: Thu Jan 01 00:00:00 1970 +0000
152 files: f
152 files: f
153 description:
153 description:
154 1
154 1
155
155
156
156
157
157
General Comments 0
You need to be logged in to leave comments. Login now