tests/test-import-eol
author Jens Bäckman <jens.backman@gmail.com>
Sun, 22 Nov 2009 19:37:19 +0100
changeset 9907 f1ee8009fe10
parent 8817 6c9dce20ed70
child 10102 1720d70cd6d4
permissions -rwxr-xr-x
i18n-sv: translated seven commands These commands has been translated: addremove, archive, backout, config, unbundle, verify, version
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8810
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     2
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     3
cat > makepatch.py <<EOF
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     4
f = file('eol.diff', 'wb')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     5
w = f.write
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     6
w('test message\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     7
w('diff --git a/a b/a\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     8
w('--- a/a\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     9
w('+++ b/a\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    10
w('@@ -1,5 +1,5 @@\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    11
w(' a\n')
8817
6c9dce20ed70 Fixed patch.eol bug that truncated all patched lines to one character
Colin Caughie <c.caughie@indigovision.com>
parents: 8810
diff changeset
    12
w('-bbb\r\n')
6c9dce20ed70 Fixed patch.eol bug that truncated all patched lines to one character
Colin Caughie <c.caughie@indigovision.com>
parents: 8810
diff changeset
    13
w('+yyyy\r\n')
6c9dce20ed70 Fixed patch.eol bug that truncated all patched lines to one character
Colin Caughie <c.caughie@indigovision.com>
parents: 8810
diff changeset
    14
w(' cc\r\n')
6c9dce20ed70 Fixed patch.eol bug that truncated all patched lines to one character
Colin Caughie <c.caughie@indigovision.com>
parents: 8810
diff changeset
    15
w(' \n')
8810
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    16
w(' d\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    17
w('-e\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    18
w('\ No newline at end of file\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    19
w('+z\r\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    20
w('\ No newline at end of file\r\n')
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    21
EOF
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    22
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    23
hg init repo
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    24
cd repo
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    25
echo '\.diff' > .hgignore
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    26
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    27
# Test different --eol values
8817
6c9dce20ed70 Fixed patch.eol bug that truncated all patched lines to one character
Colin Caughie <c.caughie@indigovision.com>
parents: 8810
diff changeset
    28
python -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")'
8810
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    29
hg ci -Am adda
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    30
python ../makepatch.py
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    31
echo % invalid eol
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    32
hg --config patch.eol='LFCR' import eol.diff
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    33
hg revert -a
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    34
echo % force LF
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    35
hg --traceback --config patch.eol='LF' import eol.diff
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    36
python -c 'print repr(file("a","rb").read())'
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    37
hg st
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    38
echo % force CRLF
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    39
hg up -C 0
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    40
hg --traceback --config patch.eol='CRLF' import eol.diff
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    41
python -c 'print repr(file("a","rb").read())'
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    42
hg st
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    43
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    44
# Test --eol and binary patches
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    45
python -c 'file("b", "wb").write("a\x00\nb")'
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    46
hg ci -Am addb
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    47
python -c 'file("b", "wb").write("a\x00\nc")'
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    48
hg diff --git > bin.diff
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    49
hg revert --no-backup b
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    50
echo % binary patch with --eol
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    51
hg import --config patch.eol='CRLF' -m changeb bin.diff
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    52
python -c 'print repr(file("b","rb").read())'
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    53
hg st
ac92775b3b80 Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    54
cd ..