tests/test-import-eol
changeset 8810 ac92775b3b80
child 8817 6c9dce20ed70
equal deleted inserted replaced
8809:6fce36336e42 8810:ac92775b3b80
       
     1 #!/bin/sh
       
     2 
       
     3 cat > makepatch.py <<EOF
       
     4 f = file('eol.diff', 'wb')
       
     5 w = f.write
       
     6 w('test message\n')
       
     7 w('diff --git a/a b/a\n')
       
     8 w('--- a/a\n')
       
     9 w('+++ b/a\n')
       
    10 w('@@ -1,5 +1,5 @@\n')
       
    11 w(' a\n')
       
    12 w('-b\r\n')
       
    13 w('+y\r\n')
       
    14 w(' c\r\n')
       
    15 w(' d\n')
       
    16 w('-e\n')
       
    17 w('\ No newline at end of file\n')
       
    18 w('+z\r\n')
       
    19 w('\ No newline at end of file\r\n')
       
    20 EOF
       
    21 
       
    22 hg init repo
       
    23 cd repo
       
    24 echo '\.diff' > .hgignore
       
    25 
       
    26 # Test different --eol values
       
    27 python -c 'file("a", "wb").write("a\nb\nc\nd\ne")'
       
    28 hg ci -Am adda
       
    29 python ../makepatch.py
       
    30 echo % invalid eol
       
    31 hg --config patch.eol='LFCR' import eol.diff
       
    32 hg revert -a
       
    33 echo % force LF
       
    34 hg --traceback --config patch.eol='LF' import eol.diff
       
    35 python -c 'print repr(file("a","rb").read())'
       
    36 hg st
       
    37 echo % force CRLF
       
    38 hg up -C 0
       
    39 hg --traceback --config patch.eol='CRLF' import eol.diff
       
    40 python -c 'print repr(file("a","rb").read())'
       
    41 hg st
       
    42 
       
    43 # Test --eol and binary patches
       
    44 python -c 'file("b", "wb").write("a\x00\nb")'
       
    45 hg ci -Am addb
       
    46 python -c 'file("b", "wb").write("a\x00\nc")'
       
    47 hg diff --git > bin.diff
       
    48 hg revert --no-backup b
       
    49 echo % binary patch with --eol
       
    50 hg import --config patch.eol='CRLF' -m changeb bin.diff
       
    51 python -c 'print repr(file("b","rb").read())'
       
    52 hg st
       
    53 cd ..