tests/test-win32text
changeset 5967 f8ad3b76e923
parent 5680 963c516bb38c
child 6210 942287cb1f57
equal deleted inserted replaced
5966:11af38a592ae 5967:f8ad3b76e923
     5 
     5 
     6 for path in sys.argv[1:]:
     6 for path in sys.argv[1:]:
     7     data = file(path, 'rb').read()
     7     data = file(path, 'rb').read()
     8     data = data.replace('\n', '\r\n')
     8     data = data.replace('\n', '\r\n')
     9     file(path, 'wb').write(data)
     9     file(path, 'wb').write(data)
       
    10 EOF
       
    11 
       
    12 cat > print.py <<EOF
       
    13 import sys
       
    14 print(sys.stdin.read().replace('\n', '<LF>').replace('\r', '<CR>').replace('\0', '<NUL>'))
    10 EOF
    15 EOF
    11 
    16 
    12 hg init
    17 hg init
    13 echo '[hooks]' >> .hg/hgrc
    18 echo '[hooks]' >> .hg/hgrc
    14 echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
    19 echo 'pretxncommit.crlf = python:hgext.win32text.forbidcrlf' >> .hg/hgrc
    60 echo
    65 echo
    61 
    66 
    62 hg log -v
    67 hg log -v
    63 echo
    68 echo
    64 
    69 
    65 # XXX missing tests for encode/decode hooks
    70 rm .hg/hgrc
       
    71 (echo some; echo text) > f3
       
    72 python -c 'file("f4.bat", "wb").write("rem empty\x0D\x0A")'
       
    73 hg add f3 f4.bat
       
    74 hg ci -m 6 -d'0 0'
       
    75 
       
    76 python print.py < bin
       
    77 python print.py < f3
       
    78 python print.py < f4.bat
       
    79 echo
       
    80 
       
    81 echo '[extensions]' >> .hg/hgrc
       
    82 echo 'win32text = ' >> .hg/hgrc
       
    83 echo '[decode]' >> .hg/hgrc
       
    84 echo '** = cleverdecode:' >> .hg/hgrc
       
    85 echo '[encode]' >> .hg/hgrc
       
    86 echo '** = cleverencode:' >> .hg/hgrc
       
    87 cat .hg/hgrc
       
    88 echo
       
    89 
       
    90 rm f3 f4.bat bin
       
    91 hg co 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))'
       
    92 python print.py < bin
       
    93 python print.py < f3
       
    94 python print.py < f4.bat
       
    95 echo
       
    96 
       
    97 python -c 'file("f5.sh", "wb").write("# empty\x0D\x0A")'
       
    98 hg add f5.sh
       
    99 hg ci -m 7 -d'0 0'
       
   100 python print.py < f5.sh
       
   101 hg cat f5.sh | python print.py