##// END OF EJS Templates
tests: unify test-encoding
Matt Mackall -
r12417:1aba1c38 default
parent child Browse files
Show More
@@ -1,62 +1,245 b''
1 #!/bin/sh
1 Test character encoding
2
3 $ hg init t
4 $ cd t
5
6 we need a repo with some legacy latin-1 changesets
2
7
3 hg init t
8 $ hg unbundle $TESTDIR/legacy-encoding.hg
4 cd t
9 adding changesets
10 adding manifests
11 adding file changes
12 added 2 changesets with 2 changes to 1 files
13 (run 'hg update' to get a working copy)
14 $ hg co
15 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
16 $ python << EOF
17 > f = file('latin-1', 'w'); f.write("latin-1 e' encoded: \xe9"); f.close()
18 > f = file('utf-8', 'w'); f.write("utf-8 e' encoded: \xc3\xa9"); f.close()
19 > f = file('latin-1-tag', 'w'); f.write("\xe9"); f.close()
20 > EOF
21
22 should fail with encoding error
5
23
6 # we need a repo with some legacy latin-1 changesets
24 $ echo "plain old ascii" > a
7 hg unbundle $TESTDIR/legacy-encoding.hg
25 $ hg st
8 hg co
26 M a
27 ? latin-1
28 ? latin-1-tag
29 ? utf-8
30 $ HGENCODING=ascii hg ci -l latin-1
31 transaction abort!
32 rollback completed
33 abort: decoding near ' encoded: �': 'ascii' codec can't decode byte 0xe9 in position 20: ordinal not in range(128)!
34 [255]
9
35
10 python << EOF
36 these should work
11 f = file('latin-1', 'w'); f.write("latin-1 e' encoded: \xe9"); f.close()
37
12 f = file('utf-8', 'w'); f.write("utf-8 e' encoded: \xc3\xa9"); f.close()
38 $ echo "latin-1" > a
13 f = file('latin-1-tag', 'w'); f.write("\xe9"); f.close()
39 $ HGENCODING=latin-1 hg ci -l latin-1
14 EOF
40 $ echo "utf-8" > a
41 $ HGENCODING=utf-8 hg ci -l utf-8
42 $ HGENCODING=latin-1 hg tag `cat latin-1-tag`
43 $ HGENCODING=latin-1 hg branch `cat latin-1-tag`
44 marked working directory as branch �
45 $ HGENCODING=latin-1 hg ci -m 'latin1 branch'
46 $ rm .hg/branch
47
48 hg log (ascii)
15
49
16 echo % should fail with encoding error
50 $ hg --encoding ascii log
17 echo "plain old ascii" > a
51 changeset: 5:093c6077d1c8
18 hg st
52 branch: ?
19 HGENCODING=ascii hg ci -l latin-1
53 tag: tip
54 user: test
55 date: Thu Jan 01 00:00:00 1970 +0000
56 summary: latin1 branch
57
58 changeset: 4:94db611b4196
59 user: test
60 date: Thu Jan 01 00:00:00 1970 +0000
61 summary: Added tag ? for changeset ca661e7520de
62
63 changeset: 3:ca661e7520de
64 tag: ?
65 user: test
66 date: Thu Jan 01 00:00:00 1970 +0000
67 summary: utf-8 e' encoded: ?
68
69 changeset: 2:650c6f3d55dd
70 user: test
71 date: Thu Jan 01 00:00:00 1970 +0000
72 summary: latin-1 e' encoded: ?
73
74 changeset: 1:0e5b7e3f9c4a
75 user: test
76 date: Mon Jan 12 13:46:40 1970 +0000
77 summary: koi8-r: ????? = u'\u0440\u0442\u0443\u0442\u044c'
78
79 changeset: 0:1e78a93102a3
80 user: test
81 date: Mon Jan 12 13:46:40 1970 +0000
82 summary: latin-1 e': ? = u'\xe9'
83
84
85 hg log (latin-1)
20
86
21 echo % these should work
87 $ hg --encoding latin-1 log
22 echo "latin-1" > a
88 changeset: 5:093c6077d1c8
23 HGENCODING=latin-1 hg ci -l latin-1
89 branch:
24 echo "utf-8" > a
90 tag: tip
25 HGENCODING=utf-8 hg ci -l utf-8
91 user: test
92 date: Thu Jan 01 00:00:00 1970 +0000
93 summary: latin1 branch
94
95 changeset: 4:94db611b4196
96 user: test
97 date: Thu Jan 01 00:00:00 1970 +0000
98 summary: Added tag for changeset ca661e7520de
99
100 changeset: 3:ca661e7520de
101 tag:
102 user: test
103 date: Thu Jan 01 00:00:00 1970 +0000
104 summary: utf-8 e' encoded: �
105
106 changeset: 2:650c6f3d55dd
107 user: test
108 date: Thu Jan 01 00:00:00 1970 +0000
109 summary: latin-1 e' encoded:
110
111 changeset: 1:0e5b7e3f9c4a
112 user: test
113 date: Mon Jan 12 13:46:40 1970 +0000
114 summary: koi8-r: ����� = u'\u0440\u0442\u0443\u0442\u044c'
115
116 changeset: 0:1e78a93102a3
117 user: test
118 date: Mon Jan 12 13:46:40 1970 +0000
119 summary: latin-1 e': � = u'\xe9'
120
26
121
27 HGENCODING=latin-1 hg tag `cat latin-1-tag`
122 hg log (utf-8)
28 HGENCODING=latin-1 hg branch `cat latin-1-tag`
29 HGENCODING=latin-1 hg ci -m 'latin1 branch'
30 rm .hg/branch
31
123
32 echo "% hg log (ascii)"
124 $ hg --encoding utf-8 log
33 hg --encoding ascii log
125 changeset: 5:093c6077d1c8
34 echo "% hg log (latin-1)"
126 branch: é
35 hg --encoding latin-1 log
127 tag: tip
36 echo "% hg log (utf-8)"
128 user: test
37 hg --encoding utf-8 log
129 date: Thu Jan 01 00:00:00 1970 +0000
38 echo "% hg tags (ascii)"
130 summary: latin1 branch
39 HGENCODING=ascii hg tags
131
40 echo "% hg tags (latin-1)"
132 changeset: 4:94db611b4196
41 HGENCODING=latin-1 hg tags
133 user: test
42 echo "% hg tags (utf-8)"
134 date: Thu Jan 01 00:00:00 1970 +0000
43 HGENCODING=utf-8 hg tags
135 summary: Added tag é for changeset ca661e7520de
44 echo "% hg branches (ascii)"
136
45 HGENCODING=ascii hg branches
137 changeset: 3:ca661e7520de
46 echo "% hg branches (latin-1)"
138 tag: é
47 HGENCODING=latin-1 hg branches
139 user: test
48 echo "% hg branches (utf-8)"
140 date: Thu Jan 01 00:00:00 1970 +0000
49 HGENCODING=utf-8 hg branches
141 summary: utf-8 e' encoded: é
142
143 changeset: 2:650c6f3d55dd
144 user: test
145 date: Thu Jan 01 00:00:00 1970 +0000
146 summary: latin-1 e' encoded: é
147
148 changeset: 1:0e5b7e3f9c4a
149 user: test
150 date: Mon Jan 12 13:46:40 1970 +0000
151 summary: koi8-r: ÒÔÕÔØ = u'\u0440\u0442\u0443\u0442\u044c'
152
153 changeset: 0:1e78a93102a3
154 user: test
155 date: Mon Jan 12 13:46:40 1970 +0000
156 summary: latin-1 e': é = u'\xe9'
157
158
159 hg tags (ascii)
160
161 $ HGENCODING=ascii hg tags
162 tip 5:093c6077d1c8
163 ? 3:ca661e7520de
164
165 hg tags (latin-1)
166
167 $ HGENCODING=latin-1 hg tags
168 tip 5:093c6077d1c8
169 3:ca661e7520de
170
171 hg tags (utf-8)
172
173 $ HGENCODING=utf-8 hg tags
174 tip 5:093c6077d1c8
175 é 3:ca661e7520de
176
177 hg branches (ascii)
178
179 $ HGENCODING=ascii hg branches
180 ? 5:093c6077d1c8
181 default 4:94db611b4196 (inactive)
182
183 hg branches (latin-1)
50
184
51 echo '[ui]' >> .hg/hgrc
185 $ HGENCODING=latin-1 hg branches
52 echo 'fallbackencoding = koi8-r' >> .hg/hgrc
186 5:093c6077d1c8
53 echo "% hg log (utf-8)"
187 default 4:94db611b4196 (inactive)
54 HGENCODING=utf-8 hg log
188
189 hg branches (utf-8)
190
191 $ HGENCODING=utf-8 hg branches
192 é 5:093c6077d1c8
193 default 4:94db611b4196 (inactive)
194 $ echo '[ui]' >> .hg/hgrc
195 $ echo 'fallbackencoding = koi8-r' >> .hg/hgrc
196
197 hg log (utf-8)
55
198
56 echo "% hg log (dolphin)"
199 $ HGENCODING=utf-8 hg log
57 HGENCODING=dolphin hg log
200 changeset: 5:093c6077d1c8
201 branch: é
202 tag: tip
203 user: test
204 date: Thu Jan 01 00:00:00 1970 +0000
205 summary: latin1 branch
206
207 changeset: 4:94db611b4196
208 user: test
209 date: Thu Jan 01 00:00:00 1970 +0000
210 summary: Added tag é for changeset ca661e7520de
211
212 changeset: 3:ca661e7520de
213 tag: é
214 user: test
215 date: Thu Jan 01 00:00:00 1970 +0000
216 summary: utf-8 e' encoded: é
217
218 changeset: 2:650c6f3d55dd
219 user: test
220 date: Thu Jan 01 00:00:00 1970 +0000
221 summary: latin-1 e' encoded: é
222
223 changeset: 1:0e5b7e3f9c4a
224 user: test
225 date: Mon Jan 12 13:46:40 1970 +0000
226 summary: koi8-r: ртуть = u'\u0440\u0442\u0443\u0442\u044c'
227
228 changeset: 0:1e78a93102a3
229 user: test
230 date: Mon Jan 12 13:46:40 1970 +0000
231 summary: latin-1 e': И = u'\xe9'
232
58
233
59 HGENCODING=ascii hg branch `cat latin-1-tag`
234 hg log (dolphin)
60 cp latin-1-tag .hg/branch
235
61 HGENCODING=latin-1 hg ci -m 'should fail'
236 $ HGENCODING=dolphin hg log
62 exit 0
237 abort: unknown encoding: dolphin, please check your locale settings
238 [255]
239 $ HGENCODING=ascii hg branch `cat latin-1-tag`
240 abort: decoding near '': 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)!
241 [255]
242 $ cp latin-1-tag .hg/branch
243 $ HGENCODING=latin-1 hg ci -m 'should fail'
244 abort: branch name not in UTF-8!
245 [255]
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now