tests/test-hybridencode.py
changeset 17432 61bd77b57c86
parent 17404 81b115385bc7
child 17440 5be041254a2e
equal deleted inserted replaced
17431:573e80049cad 17432:61bd77b57c86
     4 hybridencode = lambda f: store._hybridencode(f, auxencode)
     4 hybridencode = lambda f: store._hybridencode(f, auxencode)
     5 
     5 
     6 enc = hybridencode # used for 'dotencode' repo format
     6 enc = hybridencode # used for 'dotencode' repo format
     7 
     7 
     8 def show(s):
     8 def show(s):
     9     print "A = '%s'" % s
     9     print "A = '%s'" % s.encode("string_escape")
    10     print "B = '%s'" % enc(s)
    10     print "B = '%s'" % enc(s).encode("string_escape")
    11     print
    11     print
       
    12 
       
    13 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}")
       
    14 
       
    15 print "uppercase char X is encoded as _x"
       
    16 show("data/ABCDEFGHIJKLMNOPQRSTUVWXYZ")
       
    17 
       
    18 print "underbar is doubled"
       
    19 show("data/_")
       
    20 
       
    21 print "tilde is character-encoded"
       
    22 show("data/~")
       
    23 
       
    24 print "characters in ASCII code range 0..31"
       
    25 show('data/\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'
       
    26           '\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f')
       
    27 
       
    28 print "characters in ASCII code range 126..255 (only partially tested)"
       
    29 show('data/\x7e \x7f \x80 \x81 \x82 \x83 .. \xfd \xfe \xff')
       
    30 
       
    31 print "Windows reserved characters"
       
    32 show('data/less <, greater >, colon :, double-quote ", backslash \\'
       
    33            ', pipe |, question-mark ?, asterisk *')
       
    34 
       
    35 print "encoding directories ending in .hg, .i or .d with '.hg' suffix"
       
    36 show('data/x.hg/x.i/x.d/foo')
       
    37 
       
    38 print "but these are not encoded on *filenames*"
       
    39 show('data/foo/x.hg')
       
    40 show('data/foo/x.i')
       
    41 show('data/foo/x.d')
       
    42 
       
    43 print "plain .hg, .i and .d directories have the leading dot encoded"
       
    44 show('data/.hg/.i/.d/foo')
    12 
    45 
    13 show('data/aux.bla/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c.i')
    46 show('data/aux.bla/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c.i')
    14 
    47 
    15 show('data/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/'
    48 show('data/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/'
    16      'TENTH/ELEVENTH/LOREMIPSUM.TXT.i')
    49      'TENTH/ELEVENTH/LOREMIPSUM.TXT.i')
    22 show('data/Project Planning/Resources/AnotherLongDirectoryName/'
    55 show('data/Project Planning/Resources/AnotherLongDirectoryName/'
    23      'Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt')
    56      'Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt')
    24 show('data/Project.Planning/Resources/AnotherLongDirectoryName/'
    57 show('data/Project.Planning/Resources/AnotherLongDirectoryName/'
    25      'Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt')
    58      'Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt')
    26 show('data/foo.../foo   / /a./_. /__/.x../    bla/.FOO/something.i')
    59 show('data/foo.../foo   / /a./_. /__/.x../    bla/.FOO/something.i')
    27 show('data/com0/com1/com2/com3/com4/com5/com6/com7/com8/com9')
    60 
    28 show('data/lpt0/lpt1/lpt2/lpt3/lpt4/lpt5/lpt6/lpt7/lpt8/lpt9')
    61 show('data/c/co/com/com0/com1/com2/com3/com4/com5/com6/com7/com8/com9')
       
    62 show('data/C/CO/COM/COM0/COM1/COM2/COM3/COM4/COM5/COM6/COM7/COM8/COM9')
       
    63 show('data/c.x/co.x/com.x/com0.x/com1.x/com2.x/com3.x/com4.x/com5.x'
       
    64                                         '/com6.x/com7.x/com8.x/com9.x')
       
    65 show('data/x.c/x.co/x.com0/x.com1/x.com2/x.com3/x.com4/x.com5'
       
    66                                         '/x.com6/x.com7/x.com8/x.com9')
       
    67 show('data/cx/cox/comx/com0x/com1x/com2x/com3x/com4x/com5x'
       
    68                                             '/com6x/com7x/com8x/com9x')
       
    69 show('data/xc/xco/xcom0/xcom1/xcom2/xcom3/xcom4/xcom5'
       
    70                                             '/xcom6/xcom7/xcom8/xcom9')
       
    71 
       
    72 show('data/l/lp/lpt/lpt0/lpt1/lpt2/lpt3/lpt4/lpt5/lpt6/lpt7/lpt8/lpt9')
       
    73 show('data/L/LP/LPT/LPT0/LPT1/LPT2/LPT3/LPT4/LPT5/LPT6/LPT7/LPT8/LPT9')
       
    74 show('data/l.x/lp.x/lpt.x/lpt0.x/lpt1.x/lpt2.x/lpt3.x/lpt4.x/lpt5.x'
       
    75                                         '/lpt6.x/lpt7.x/lpt8.x/lpt9.x')
       
    76 show('data/x.l/x.lp/x.lpt/x.lpt0/x.lpt1/x.lpt2/x.lpt3/x.lpt4/x.lpt5'
       
    77                                         '/x.lpt6/x.lpt7/x.lpt8/x.lpt9')
       
    78 show('data/lx/lpx/lptx/lpt0x/lpt1x/lpt2x/lpt3x/lpt4x/lpt5x'
       
    79                                             '/lpt6x/lpt7x/lpt8x/lpt9x')
       
    80 show('data/xl/xlp/xlpt/xlpt0/xlpt1/xlpt2/xlpt3/xlpt4/xlpt5'
       
    81                                             '/xlpt6/xlpt7/xlpt8/xlpt9')
       
    82 
       
    83 show('data/con/p/pr/prn/a/au/aux/n/nu/nul')
       
    84 show('data/CON/P/PR/PRN/A/AU/AUX/N/NU/NUL')
       
    85 show('data/con.x/p.x/pr.x/prn.x/a.x/au.x/aux.x/n.x/nu.x/nul.x')
       
    86 show('data/x.con/x.p/x.pr/x.prn/x.a/x.au/x.aux/x.n/x.nu/x.nul')
       
    87 show('data/conx/px/prx/prnx/ax/aux/auxx/nx/nux/nulx')
       
    88 show('data/xcon/xp/xpr/xprn/xa/xau/xaux/xn/xnu/xnul')
       
    89 
       
    90 print "largest unhashed path"
       
    91 show('data/123456789-123456789-123456789-123456789-123456789-'
       
    92           'unhashed--xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
       
    93           '123456789-12345')
       
    94 
       
    95 print "shortest hashed path"
       
    96 show('data/123456789-123456789-123456789-123456789-123456789-'
       
    97           'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-'
       
    98           '123456789-123456')
       
    99 
       
   100 print "changing one char in part that's hashed away produces a different hash"
       
   101 show('data/123456789-123456789-123456789-123456789-123456789-'
       
   102           'hashed----xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxxxxy-'
       
   103           '123456789-123456')