Show More
@@ -1,286 +1,286 | |||
|
1 | 1 | Test character encoding |
|
2 | 2 | |
|
3 | 3 | $ hg init t |
|
4 | 4 | $ cd t |
|
5 | 5 | |
|
6 | 6 | we need a repo with some legacy latin-1 changesets |
|
7 | 7 | |
|
8 | 8 | $ hg unbundle "$TESTDIR/bundles/legacy-encoding.hg" |
|
9 | 9 | adding changesets |
|
10 | 10 | adding manifests |
|
11 | 11 | adding file changes |
|
12 | 12 | added 2 changesets with 2 changes to 1 files |
|
13 | 13 | new changesets 1e78a93102a3:0e5b7e3f9c4a |
|
14 | 14 | (run 'hg update' to get a working copy) |
|
15 | 15 | $ hg co |
|
16 | 16 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
17 | 17 | $ $PYTHON << EOF |
|
18 |
> f = |
|
|
19 |
> f = |
|
|
20 |
> f = |
|
|
18 | > f = open('latin-1', 'wb'); f.write(b"latin-1 e' encoded: \xe9"); f.close() | |
|
19 | > f = open('utf-8', 'wb'); f.write(b"utf-8 e' encoded: \xc3\xa9"); f.close() | |
|
20 | > f = open('latin-1-tag', 'wb'); f.write(b"\xe9"); f.close() | |
|
21 | 21 | > EOF |
|
22 | 22 | |
|
23 | 23 | should fail with encoding error |
|
24 | 24 | |
|
25 | 25 | $ echo "plain old ascii" > a |
|
26 | 26 | $ hg st |
|
27 | 27 | M a |
|
28 | 28 | ? latin-1 |
|
29 | 29 | ? latin-1-tag |
|
30 | 30 | ? utf-8 |
|
31 | 31 | $ HGENCODING=ascii hg ci -l latin-1 |
|
32 | 32 | transaction abort! |
|
33 | 33 | rollback completed |
|
34 | 34 | abort: decoding near ' encoded: \xe9': 'ascii' codec can't decode byte 0xe9 in position 20: ordinal not in range(128)! (esc) |
|
35 | 35 | [255] |
|
36 | 36 | |
|
37 | 37 | these should work |
|
38 | 38 | |
|
39 | 39 | $ echo "latin-1" > a |
|
40 | 40 | $ HGENCODING=latin-1 hg ci -l latin-1 |
|
41 | 41 | $ echo "utf-8" > a |
|
42 | 42 | $ HGENCODING=utf-8 hg ci -l utf-8 |
|
43 | 43 | $ HGENCODING=latin-1 hg tag `cat latin-1-tag` |
|
44 | 44 | $ HGENCODING=latin-1 hg branch `cat latin-1-tag` |
|
45 | 45 | marked working directory as branch \xe9 (esc) |
|
46 | 46 | (branches are permanent and global, did you want a bookmark?) |
|
47 | 47 | $ HGENCODING=latin-1 hg ci -m 'latin1 branch' |
|
48 | 48 | $ hg -q rollback |
|
49 | 49 | $ HGENCODING=latin-1 hg branch |
|
50 | 50 | \xe9 (esc) |
|
51 | 51 | $ HGENCODING=latin-1 hg ci -m 'latin1 branch' |
|
52 | 52 | $ rm .hg/branch |
|
53 | 53 | |
|
54 | 54 | hg log (ascii) |
|
55 | 55 | |
|
56 | 56 | $ hg --encoding ascii log |
|
57 | 57 | changeset: 5:a52c0692f24a |
|
58 | 58 | branch: ? |
|
59 | 59 | tag: tip |
|
60 | 60 | user: test |
|
61 | 61 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
62 | 62 | summary: latin1 branch |
|
63 | 63 | |
|
64 | 64 | changeset: 4:94db611b4196 |
|
65 | 65 | user: test |
|
66 | 66 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
67 | 67 | summary: Added tag ? for changeset ca661e7520de |
|
68 | 68 | |
|
69 | 69 | changeset: 3:ca661e7520de |
|
70 | 70 | tag: ? |
|
71 | 71 | user: test |
|
72 | 72 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
73 | 73 | summary: utf-8 e' encoded: ? |
|
74 | 74 | |
|
75 | 75 | changeset: 2:650c6f3d55dd |
|
76 | 76 | user: test |
|
77 | 77 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
78 | 78 | summary: latin-1 e' encoded: ? |
|
79 | 79 | |
|
80 | 80 | changeset: 1:0e5b7e3f9c4a |
|
81 | 81 | user: test |
|
82 | 82 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
83 | 83 | summary: koi8-r: ????? = u'\u0440\u0442\u0443\u0442\u044c' |
|
84 | 84 | |
|
85 | 85 | changeset: 0:1e78a93102a3 |
|
86 | 86 | user: test |
|
87 | 87 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
88 | 88 | summary: latin-1 e': ? = u'\xe9' |
|
89 | 89 | |
|
90 | 90 | |
|
91 | 91 | hg log (latin-1) |
|
92 | 92 | |
|
93 | 93 | $ hg --encoding latin-1 log |
|
94 | 94 | changeset: 5:a52c0692f24a |
|
95 | 95 | branch: \xe9 (esc) |
|
96 | 96 | tag: tip |
|
97 | 97 | user: test |
|
98 | 98 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
99 | 99 | summary: latin1 branch |
|
100 | 100 | |
|
101 | 101 | changeset: 4:94db611b4196 |
|
102 | 102 | user: test |
|
103 | 103 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
104 | 104 | summary: Added tag \xe9 for changeset ca661e7520de (esc) |
|
105 | 105 | |
|
106 | 106 | changeset: 3:ca661e7520de |
|
107 | 107 | tag: \xe9 (esc) |
|
108 | 108 | user: test |
|
109 | 109 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
110 | 110 | summary: utf-8 e' encoded: \xe9 (esc) |
|
111 | 111 | |
|
112 | 112 | changeset: 2:650c6f3d55dd |
|
113 | 113 | user: test |
|
114 | 114 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
115 | 115 | summary: latin-1 e' encoded: \xe9 (esc) |
|
116 | 116 | |
|
117 | 117 | changeset: 1:0e5b7e3f9c4a |
|
118 | 118 | user: test |
|
119 | 119 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
120 | 120 | summary: koi8-r: \xd2\xd4\xd5\xd4\xd8 = u'\\u0440\\u0442\\u0443\\u0442\\u044c' (esc) |
|
121 | 121 | |
|
122 | 122 | changeset: 0:1e78a93102a3 |
|
123 | 123 | user: test |
|
124 | 124 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
125 | 125 | summary: latin-1 e': \xe9 = u'\\xe9' (esc) |
|
126 | 126 | |
|
127 | 127 | |
|
128 | 128 | hg log (utf-8) |
|
129 | 129 | |
|
130 | 130 | $ hg --encoding utf-8 log |
|
131 | 131 | changeset: 5:a52c0692f24a |
|
132 | 132 | branch: \xc3\xa9 (esc) |
|
133 | 133 | tag: tip |
|
134 | 134 | user: test |
|
135 | 135 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
136 | 136 | summary: latin1 branch |
|
137 | 137 | |
|
138 | 138 | changeset: 4:94db611b4196 |
|
139 | 139 | user: test |
|
140 | 140 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
141 | 141 | summary: Added tag \xc3\xa9 for changeset ca661e7520de (esc) |
|
142 | 142 | |
|
143 | 143 | changeset: 3:ca661e7520de |
|
144 | 144 | tag: \xc3\xa9 (esc) |
|
145 | 145 | user: test |
|
146 | 146 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
147 | 147 | summary: utf-8 e' encoded: \xc3\xa9 (esc) |
|
148 | 148 | |
|
149 | 149 | changeset: 2:650c6f3d55dd |
|
150 | 150 | user: test |
|
151 | 151 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
152 | 152 | summary: latin-1 e' encoded: \xc3\xa9 (esc) |
|
153 | 153 | |
|
154 | 154 | changeset: 1:0e5b7e3f9c4a |
|
155 | 155 | user: test |
|
156 | 156 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
157 | 157 | summary: koi8-r: \xc3\x92\xc3\x94\xc3\x95\xc3\x94\xc3\x98 = u'\\u0440\\u0442\\u0443\\u0442\\u044c' (esc) |
|
158 | 158 | |
|
159 | 159 | changeset: 0:1e78a93102a3 |
|
160 | 160 | user: test |
|
161 | 161 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
162 | 162 | summary: latin-1 e': \xc3\xa9 = u'\\xe9' (esc) |
|
163 | 163 | |
|
164 | 164 | |
|
165 | 165 | hg tags (ascii) |
|
166 | 166 | |
|
167 | 167 | $ HGENCODING=ascii hg tags |
|
168 | 168 | tip 5:a52c0692f24a |
|
169 | 169 | ? 3:ca661e7520de |
|
170 | 170 | |
|
171 | 171 | hg tags (latin-1) |
|
172 | 172 | |
|
173 | 173 | $ HGENCODING=latin-1 hg tags |
|
174 | 174 | tip 5:a52c0692f24a |
|
175 | 175 | \xe9 3:ca661e7520de (esc) |
|
176 | 176 | |
|
177 | 177 | hg tags (utf-8) |
|
178 | 178 | |
|
179 | 179 | $ HGENCODING=utf-8 hg tags |
|
180 | 180 | tip 5:a52c0692f24a |
|
181 | 181 | \xc3\xa9 3:ca661e7520de (esc) |
|
182 | 182 | |
|
183 | 183 | hg tags (JSON) |
|
184 | 184 | |
|
185 | 185 | $ hg tags -Tjson |
|
186 | 186 | [ |
|
187 | 187 | { |
|
188 | 188 | "node": "a52c0692f24ad921c0a31e1736e7635a8b23b670", |
|
189 | 189 | "rev": 5, |
|
190 | 190 | "tag": "tip", |
|
191 | 191 | "type": "" |
|
192 | 192 | }, |
|
193 | 193 | { |
|
194 | 194 | "node": "ca661e7520dec3f5438a63590c350bebadb04989", |
|
195 | 195 | "rev": 3, |
|
196 | 196 | "tag": "\xc3\xa9", (esc) |
|
197 | 197 | "type": "" |
|
198 | 198 | } |
|
199 | 199 | ] |
|
200 | 200 | |
|
201 | 201 | hg branches (ascii) |
|
202 | 202 | |
|
203 | 203 | $ HGENCODING=ascii hg branches |
|
204 | 204 | ? 5:a52c0692f24a |
|
205 | 205 | default 4:94db611b4196 (inactive) |
|
206 | 206 | |
|
207 | 207 | hg branches (latin-1) |
|
208 | 208 | |
|
209 | 209 | $ HGENCODING=latin-1 hg branches |
|
210 | 210 | \xe9 5:a52c0692f24a (esc) |
|
211 | 211 | default 4:94db611b4196 (inactive) |
|
212 | 212 | |
|
213 | 213 | hg branches (utf-8) |
|
214 | 214 | |
|
215 | 215 | $ HGENCODING=utf-8 hg branches |
|
216 | 216 | \xc3\xa9 5:a52c0692f24a (esc) |
|
217 | 217 | default 4:94db611b4196 (inactive) |
|
218 | 218 | $ echo '[ui]' >> .hg/hgrc |
|
219 | 219 | $ echo 'fallbackencoding = koi8-r' >> .hg/hgrc |
|
220 | 220 | |
|
221 | 221 | hg log (utf-8) |
|
222 | 222 | |
|
223 | 223 | $ HGENCODING=utf-8 hg log |
|
224 | 224 | changeset: 5:a52c0692f24a |
|
225 | 225 | branch: \xc3\xa9 (esc) |
|
226 | 226 | tag: tip |
|
227 | 227 | user: test |
|
228 | 228 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
229 | 229 | summary: latin1 branch |
|
230 | 230 | |
|
231 | 231 | changeset: 4:94db611b4196 |
|
232 | 232 | user: test |
|
233 | 233 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
234 | 234 | summary: Added tag \xc3\xa9 for changeset ca661e7520de (esc) |
|
235 | 235 | |
|
236 | 236 | changeset: 3:ca661e7520de |
|
237 | 237 | tag: \xc3\xa9 (esc) |
|
238 | 238 | user: test |
|
239 | 239 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
240 | 240 | summary: utf-8 e' encoded: \xc3\xa9 (esc) |
|
241 | 241 | |
|
242 | 242 | changeset: 2:650c6f3d55dd |
|
243 | 243 | user: test |
|
244 | 244 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
245 | 245 | summary: latin-1 e' encoded: \xc3\xa9 (esc) |
|
246 | 246 | |
|
247 | 247 | changeset: 1:0e5b7e3f9c4a |
|
248 | 248 | user: test |
|
249 | 249 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
250 | 250 | summary: koi8-r: \xd1\x80\xd1\x82\xd1\x83\xd1\x82\xd1\x8c = u'\\u0440\\u0442\\u0443\\u0442\\u044c' (esc) |
|
251 | 251 | |
|
252 | 252 | changeset: 0:1e78a93102a3 |
|
253 | 253 | user: test |
|
254 | 254 | date: Mon Jan 12 13:46:40 1970 +0000 |
|
255 | 255 | summary: latin-1 e': \xd0\x98 = u'\\xe9' (esc) |
|
256 | 256 | |
|
257 | 257 | |
|
258 | 258 | hg log (dolphin) |
|
259 | 259 | |
|
260 | 260 | $ HGENCODING=dolphin hg log |
|
261 | 261 | abort: unknown encoding: dolphin |
|
262 | 262 | (please check your locale settings) |
|
263 | 263 | [255] |
|
264 | 264 | $ HGENCODING=ascii hg branch `cat latin-1-tag` |
|
265 | 265 | abort: decoding near '\xe9': 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)! (esc) |
|
266 | 266 | [255] |
|
267 | 267 | $ cp latin-1-tag .hg/branch |
|
268 | 268 | $ HGENCODING=latin-1 hg ci -m 'auto-promote legacy name' |
|
269 | 269 | |
|
270 | 270 | Test roundtrip encoding of lookup tables when not using UTF-8 (issue2763) |
|
271 | 271 | |
|
272 | 272 | $ HGENCODING=latin-1 hg up `cat latin-1-tag` |
|
273 | 273 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
274 | 274 | |
|
275 | 275 | $ cd .. |
|
276 | 276 | |
|
277 | 277 | Test roundtrip encoding/decoding of utf8b for generated data |
|
278 | 278 | |
|
279 | 279 | #if hypothesis |
|
280 | 280 | |
|
281 | 281 | >>> from hypothesishelpers import * |
|
282 | 282 | >>> from mercurial import encoding |
|
283 | 283 | >>> roundtrips(st.binary(), encoding.fromutf8b, encoding.toutf8b) |
|
284 | 284 | Round trip OK |
|
285 | 285 | |
|
286 | 286 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now