##// END OF EJS Templates
py3: use print_function in test-hybridencode.py
Robert Stanca -
r28750:2b0d7be9 default
parent child Browse files
Show More
@@ -57,7 +57,6 b''
57 57 tests/test-demandimport.py requires print_function
58 58 tests/test-doctest.py not using absolute_import
59 59 tests/test-hgwebdir-paths.py not using absolute_import
60 tests/test-hybridencode.py requires print_function
61 60 tests/test-lrucachedict.py not using absolute_import
62 61 tests/test-lrucachedict.py requires print_function
63 62 tests/test-manifest.py not using absolute_import
@@ -237,7 +236,6 b''
237 236 mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
238 237 tests/readlink.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
239 238 tests/test-demandimport.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
240 tests/test-hybridencode.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
241 239 tests/test-lrucachedict.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
242 240 tests/test-minirst.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
243 241 tests/test-parseindex*.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line *) (glob)
@@ -1,38 +1,38 b''
1 from __future__ import absolute_import
1 from __future__ import absolute_import, print_function
2 2 from mercurial import (
3 3 store,
4 4 )
5 5
6 6 def show(s):
7 7 # show test input
8 print "A = '%s'" % s.encode("string_escape")
8 print("A = '%s'" % s.encode("string_escape"))
9 9
10 10 # show the result of the C implementation, if available
11 11 h = store._pathencode(s)
12 print "B = '%s'" % h.encode("string_escape")
12 print("B = '%s'" % h.encode("string_escape"))
13 13
14 14 # compare it with reference implementation in Python
15 15 r = store._hybridencode(s, True)
16 16 if h != r:
17 print "R = '%s'" % r.encode("string_escape")
18 print
17 print("R = '%s'" % r.encode("string_escape"))
18 print()
19 19
20 20 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}")
21 21
22 print "uppercase char X is encoded as _x"
22 print("uppercase char X is encoded as _x")
23 23 show("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ")
24 24
25 print "underbar is doubled"
25 print("underbar is doubled")
26 26 show("data/_")
27 27
28 print "tilde is character-encoded"
28 print("tilde is character-encoded")
29 29 show("data/~")
30 30
31 print "characters in ASCII code range 1..31"
31 print("characters in ASCII code range 1..31")
32 32 show('data/\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'
33 33 '\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f')
34 34
35 print "characters in ASCII code range 126..255"
35 print("characters in ASCII code range 126..255")
36 36 show('data/\x7e\x7f'
37 37 '\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f'
38 38 '\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f')
@@ -43,18 +43,18 b" show('data/\\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\"
43 43 show('data/\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef'
44 44 '\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff')
45 45
46 print "Windows reserved characters"
46 print("Windows reserved characters")
47 47 show('data/less <, greater >, colon :, double-quote ", backslash \\'
48 48 ', pipe |, question-mark ?, asterisk *')
49 49
50 print "encoding directories ending in .hg, .i or .d with '.hg' suffix"
50 print("encoding directories ending in .hg, .i or .d with '.hg' suffix")
51 51 show('data/x.h.i/x.hg/x.i/x.d/foo')
52 52 show('data/a.hg/a.i/a.d/foo')
53 53 show('data/au.hg/au.i/au.d/foo')
54 54 show('data/aux.hg/aux.i/aux.d/foo')
55 55 show('data/auxy.hg/auxy.i/auxy.d/foo')
56 56
57 print "but these are not encoded on *filenames*"
57 print("but these are not encoded on *filenames*")
58 58 show('data/foo/x.hg')
59 59 show('data/foo/x.i')
60 60 show('data/foo/x.d')
@@ -71,7 +71,7 b" show('data/foo/auxy.hg')"
71 71 show('data/foo/auxy.i')
72 72 show('data/foo/auxy.d')
73 73
74 print "plain .hg, .i and .d directories have the leading dot encoded"
74 print("plain .hg, .i and .d directories have the leading dot encoded")
75 75 show('data/.hg/.i/.d/foo')
76 76
77 77 show('data/aux.bla/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c.i')
@@ -129,22 +129,22 b" show('data/com9./com9y./com9.')"
129 129
130 130 show('data/a /au /aux /auxy /aux ')
131 131
132 print "largest unhashed path"
132 print("largest unhashed path")
133 133 show('data/123456789-123456789-123456789-123456789-123456789-'
134 134 'unhashed--xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
135 135 '123456789-12345')
136 136
137 print "shortest hashed path"
137 print("shortest hashed path")
138 138 show('data/123456789-123456789-123456789-123456789-123456789-'
139 139 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
140 140 '123456789-123456')
141 141
142 print "changing one char in part that's hashed away produces a different hash"
142 print("changing one char in part that's hashed away produces a different hash")
143 143 show('data/123456789-123456789-123456789-123456789-123456789-'
144 144 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxy-'
145 145 '123456789-123456')
146 146
147 print "uppercase hitting length limit due to encoding"
147 print("uppercase hitting length limit due to encoding")
148 148 show('data/A23456789-123456789-123456789-123456789-123456789-'
149 149 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
150 150 '123456789-12345')
@@ -152,7 +152,7 b" show('data/Z23456789-123456789-123456789"
152 152 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
153 153 '123456789-12345')
154 154
155 print "compare with lowercase not hitting limit"
155 print("compare with lowercase not hitting limit")
156 156 show('data/a23456789-123456789-123456789-123456789-123456789-'
157 157 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
158 158 '123456789-12345')
@@ -160,22 +160,22 b" show('data/z23456789-123456789-123456789"
160 160 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
161 161 '123456789-12345')
162 162
163 print "not hitting limit with any of these"
163 print("not hitting limit with any of these")
164 164 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;="
165 165 "[]^`{}xxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-"
166 166 "123456789-12345")
167 167
168 print "underbar hitting length limit due to encoding"
168 print("underbar hitting length limit due to encoding")
169 169 show('data/_23456789-123456789-123456789-123456789-123456789-'
170 170 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
171 171 '123456789-12345')
172 172
173 print "tilde hitting length limit due to encoding"
173 print("tilde hitting length limit due to encoding")
174 174 show('data/~23456789-123456789-123456789-123456789-123456789-'
175 175 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
176 176 '123456789-12345')
177 177
178 print "Windows reserved characters hitting length limit"
178 print("Windows reserved characters hitting length limit")
179 179 show('data/<23456789-123456789-123456789-123456789-123456789-'
180 180 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
181 181 '123456789-12345')
@@ -201,47 +201,47 b" show('data/*23456789-123456789-123456789"
201 201 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
202 202 '123456789-12345')
203 203
204 print "initial space hitting length limit"
204 print("initial space hitting length limit")
205 205 show('data/ 23456789-123456789-123456789-123456789-123456789-'
206 206 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
207 207 '123456789-12345')
208 208
209 print "initial dot hitting length limit"
209 print("initial dot hitting length limit")
210 210 show('data/.23456789-123456789-123456789-123456789-123456789-'
211 211 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
212 212 '123456789-12345')
213 213
214 print "trailing space in filename hitting length limit"
214 print("trailing space in filename hitting length limit")
215 215 show('data/123456789-123456789-123456789-123456789-123456789-'
216 216 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
217 217 '123456789-1234 ')
218 218
219 print "trailing dot in filename hitting length limit"
219 print("trailing dot in filename hitting length limit")
220 220 show('data/123456789-123456789-123456789-123456789-123456789-'
221 221 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
222 222 '123456789-1234.')
223 223
224 print "initial space in directory hitting length limit"
224 print("initial space in directory hitting length limit")
225 225 show('data/ x/456789-123456789-123456789-123456789-123456789-'
226 226 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
227 227 '123456789-12345')
228 228
229 print "initial dot in directory hitting length limit"
229 print("initial dot in directory hitting length limit")
230 230 show('data/.x/456789-123456789-123456789-123456789-123456789-'
231 231 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
232 232 '123456789-12345')
233 233
234 print "trailing space in directory hitting length limit"
234 print("trailing space in directory hitting length limit")
235 235 show('data/x /456789-123456789-123456789-123456789-123456789-'
236 236 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
237 237 '123456789-12345')
238 238
239 print "trailing dot in directory hitting length limit"
239 print("trailing dot in directory hitting length limit")
240 240 show('data/x./456789-123456789-123456789-123456789-123456789-'
241 241 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
242 242 '123456789-12345')
243 243
244 print "with directories that need direncoding, hitting length limit"
244 print("with directories that need direncoding, hitting length limit")
245 245 show('data/x.i/56789-123456789-123456789-123456789-123456789-'
246 246 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
247 247 '123456789-12345')
@@ -252,7 +252,7 b" show('data/x.hg/5789-123456789-123456789"
252 252 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
253 253 '123456789-12345')
254 254
255 print "Windows reserved filenames, hitting length limit"
255 print("Windows reserved filenames, hitting length limit")
256 256 show('data/con/56789-123456789-123456789-123456789-123456789-'
257 257 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
258 258 '123456789-12345')
@@ -278,100 +278,100 b" show('data/lpt9/6789-123456789-123456789"
278 278 'xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
279 279 '123456789-12345')
280 280
281 print "non-reserved names, just not hitting limit"
281 print("non-reserved names, just not hitting limit")
282 282 show('data/123456789-123456789-123456789-123456789-123456789-'
283 283 '/com/com0/lpt/lpt0/-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
284 284 '123456789-12345')
285 285
286 print "hashed path with largest untruncated 1st dir"
286 print("hashed path with largest untruncated 1st dir")
287 287 show('data/12345678/-123456789-123456789-123456789-123456789-'
288 288 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
289 289 '123456789-123456')
290 290
291 print "hashed path with smallest truncated 1st dir"
291 print("hashed path with smallest truncated 1st dir")
292 292 show('data/123456789/123456789-123456789-123456789-123456789-'
293 293 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
294 294 '123456789-123456')
295 295
296 print "hashed path with largest untruncated two dirs"
296 print("hashed path with largest untruncated two dirs")
297 297 show('data/12345678/12345678/9-123456789-123456789-123456789-'
298 298 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
299 299 '123456789-123456')
300 300
301 print "hashed path with smallest truncated two dirs"
301 print("hashed path with smallest truncated two dirs")
302 302 show('data/123456789/123456789/123456789-123456789-123456789-'
303 303 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
304 304 '123456789-123456')
305 305
306 print "hashed path with largest untruncated three dirs"
306 print("hashed path with largest untruncated three dirs")
307 307 show('data/12345678/12345678/12345678/89-123456789-123456789-'
308 308 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
309 309 '123456789-123456')
310 310
311 print "hashed path with smallest truncated three dirs"
311 print("hashed path with smallest truncated three dirs")
312 312 show('data/123456789/123456789/123456789/123456789-123456789-'
313 313 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
314 314 '123456789-123456')
315 315
316 print "hashed path with largest untruncated four dirs"
316 print("hashed path with largest untruncated four dirs")
317 317 show('data/12345678/12345678/12345678/12345678/789-123456789-'
318 318 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
319 319 '123456789-123456')
320 320
321 print "hashed path with smallest truncated four dirs"
321 print("hashed path with smallest truncated four dirs")
322 322 show('data/123456789/123456789/123456789/123456789/123456789-'
323 323 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
324 324 '123456789-123456')
325 325
326 print "hashed path with largest untruncated five dirs"
326 print("hashed path with largest untruncated five dirs")
327 327 show('data/12345678/12345678/12345678/12345678/12345678/6789-'
328 328 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
329 329 '123456789-123456')
330 330
331 print "hashed path with smallest truncated five dirs"
331 print("hashed path with smallest truncated five dirs")
332 332 show('data/123456789/123456789/123456789/123456789/123456789/'
333 333 'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
334 334 '123456789-123456')
335 335
336 print "hashed path with largest untruncated six dirs"
336 print("hashed path with largest untruncated six dirs")
337 337 show('data/12345678/12345678/12345678/12345678/12345678/12345'
338 338 '678/ed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
339 339 '123456789-123456')
340 340
341 print "hashed path with smallest truncated six dirs"
341 print("hashed path with smallest truncated six dirs")
342 342 show('data/123456789/123456789/123456789/123456789/123456789/'
343 343 '123456789/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
344 344 '123456789-123456')
345 345
346 print "hashed path with largest untruncated seven dirs"
346 print("hashed path with largest untruncated seven dirs")
347 347 show('data/12345678/12345678/12345678/12345678/12345678/12345'
348 348 '678/12345678/xxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
349 349 '123456789-123456')
350 350
351 print "hashed path with smallest truncated seven dirs"
351 print("hashed path with smallest truncated seven dirs")
352 352 show('data/123456789/123456789/123456789/123456789/123456789/'
353 353 '123456789/123456789/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
354 354 '123456789-123456')
355 355
356 print "hashed path with largest untruncated eight dirs"
357 print "(directory 8 is dropped because it hits _maxshortdirslen)"
356 print("hashed path with largest untruncated eight dirs")
357 print("(directory 8 is dropped because it hits _maxshortdirslen)")
358 358 show('data/12345678/12345678/12345678/12345678/12345678/12345'
359 359 '678/12345678/12345678/xxxxxxx-xxxxxxxxx-xxxxxxxxx-'
360 360 '123456789-123456')
361 361
362 print "hashed path with smallest truncated eight dirs"
363 print "(directory 8 is dropped because it hits _maxshortdirslen)"
362 print("hashed path with smallest truncated eight dirs")
363 print("(directory 8 is dropped because it hits _maxshortdirslen)")
364 364 show('data/123456789/123456789/123456789/123456789/123456789/'
365 365 '123456789/123456789/123456789/xxxxxxxxx-xxxxxxxxx-'
366 366 '123456789-123456')
367 367
368 print "hashed path with largest non-dropped directory 8"
369 print "(just not hitting the _maxshortdirslen boundary)"
368 print("hashed path with largest non-dropped directory 8")
369 print("(just not hitting the _maxshortdirslen boundary)")
370 370 show('data/12345678/12345678/12345678/12345678/12345678/12345'
371 371 '678/12345678/12345/-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
372 372 '123456789-123456')
373 373
374 print "...adding one truncated char to dir 1..7 won't drop dir 8"
374 print("...adding one truncated char to dir 1..7 won't drop dir 8")
375 375 show('data/12345678x/12345678/12345678/12345678/12345678/12345'
376 376 '678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
377 377 '123456789-123456')
@@ -394,14 +394,14 b" show('data/12345678/12345678/12345678/12"
394 394 '678/12345678x/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
395 395 '123456789-123456')
396 396
397 print "hashed path with shortest dropped directory 8"
398 print "(just hitting the _maxshortdirslen boundary)"
397 print("hashed path with shortest dropped directory 8")
398 print("(just hitting the _maxshortdirslen boundary)")
399 399 show('data/12345678/12345678/12345678/12345678/12345678/12345'
400 400 '678/12345678/123456/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
401 401 '123456789-123456')
402 402
403 print "hashed path that drops dir 8 due to dot or space at end is"
404 print "encoded, and thus causing to hit _maxshortdirslen"
403 print("hashed path that drops dir 8 due to dot or space at end is")
404 print("encoded, and thus causing to hit _maxshortdirslen")
405 405 show('data/12345678/12345678/12345678/12345678/12345678/12345'
406 406 '678/12345678/1234./-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
407 407 '123456789-123456')
@@ -409,7 +409,7 b" show('data/12345678/12345678/12345678/12"
409 409 '678/12345678/1234 /-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
410 410 '123456789-123456')
411 411
412 print "... with dir 8 short enough for encoding"
412 print("... with dir 8 short enough for encoding")
413 413 show('data/12345678/12345678/12345678/12345678/12345678/12345'
414 414 '678/12345678/12./xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
415 415 '123456789-123456')
@@ -417,9 +417,9 b" show('data/12345678/12345678/12345678/12"
417 417 '678/12345678/12 /xx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
418 418 '123456789-123456')
419 419
420 print '''Extensions are replicated on hashed paths. Note that
420 print('''Extensions are replicated on hashed paths. Note that
421 421 we only get to encode files that end in .i or .d inside the
422 store. Encoded filenames are thus bound in length.'''
422 store. Encoded filenames are thus bound in length.''')
423 423 show('data/12345678/12345678/12345678/12345678/12345678/12345'
424 424 '678/12345678/12345/-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
425 425 '123456789-12.345.i')
@@ -464,7 +464,7 b" show('data/12345678/12345678/12345678/12"
464 464 'xxxxx-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwww'
465 465 'wwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww.i')
466 466
467 print "paths outside data/ can be encoded"
467 print("paths outside data/ can be encoded")
468 468 show('metadata/dir/00manifest.i')
469 469 show('metadata/12345678/12345678/12345678/12345678/12345678/'
470 470 '12345678/12345678/12345678/12345678/12345678/12345678/'
General Comments 0
You need to be logged in to leave comments. Login now