author | Steve Borho <steve@borho.org> |
Fri, 17 Sep 2010 12:44:35 -0500 | |
branch | stable |
changeset 12317 | ed639917c825 |
parent 10130 | 7936cd261dc9 |
permissions | -rwxr-xr-x |
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 |
10102
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
31 |
|
8810
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 |
echo % invalid eol |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
33 |
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
|
34 |
hg revert -a |
10102
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
35 |
|
8810
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
36 |
echo % force LF |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
37 |
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
|
38 |
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
|
39 |
hg st |
10102
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
40 |
|
8810
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
41 |
echo % force CRLF |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
42 |
hg up -C 0 |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
43 |
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
|
44 |
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
|
45 |
hg st |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
46 |
|
10102
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
47 |
echo % auto EOL on LF file |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
48 |
hg up -C 0 |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
49 |
hg --traceback --config patch.eol='auto' import eol.diff |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
50 |
python -c 'print repr(file("a","rb").read())' |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
51 |
hg st |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
52 |
|
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
53 |
echo % auto EOL on CRLF file |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
54 |
python -c 'file("a", "wb").write("a\r\nbbb\r\ncc\r\n\r\nd\r\ne")' |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
55 |
hg commit -m 'switch EOLs in a' |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
56 |
hg --traceback --config patch.eol='auto' import eol.diff |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
57 |
python -c 'print repr(file("a","rb").read())' |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
58 |
hg st |
1720d70cd6d4
patch: implement patch.eol=auto mode
Martin Geisler <mg@lazybytes.net>
parents:
8817
diff
changeset
|
59 |
|
10127
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
60 |
echo % auto EOL on new file or source without any EOL |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
61 |
python -c 'file("noeol", "wb").write("noeol")' |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
62 |
hg add noeol |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
63 |
hg commit -m 'add noeol' |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
64 |
python -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")' |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
65 |
python -c 'file("neweol", "wb").write("neweol\nneweol\r\n")' |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
66 |
hg add neweol |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
67 |
hg diff --git > noeol.diff |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
68 |
hg revert --no-backup noeol neweol |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
69 |
rm neweol |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
70 |
hg --traceback --config patch.eol='auto' import -m noeol noeol.diff |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
71 |
python -c 'print repr(file("noeol","rb").read())' |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
72 |
python -c 'print repr(file("neweol","rb").read())' |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
73 |
hg st |
d8214e944b84
patch: fix eolmode=auto with new files
Patrick Mezard <pmezard@gmail.com>
parents:
10102
diff
changeset
|
74 |
|
8810
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
75 |
# Test --eol and binary patches |
10130
7936cd261dc9
test-import-eol: improve binary hunks test
Patrick Mezard <pmezard@gmail.com>
parents:
10127
diff
changeset
|
76 |
python -c 'file("b", "wb").write("a\x00\nb\r\nd")' |
8810
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
77 |
hg ci -Am addb |
10130
7936cd261dc9
test-import-eol: improve binary hunks test
Patrick Mezard <pmezard@gmail.com>
parents:
10127
diff
changeset
|
78 |
python -c 'file("b", "wb").write("a\x00\nc\r\nd")' |
8810
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
79 |
hg diff --git > bin.diff |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
80 |
hg revert --no-backup b |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
81 |
echo % binary patch with --eol |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
82 |
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
|
83 |
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
|
84 |
hg st |
ac92775b3b80
Add patch.eol to ignore EOLs when patching (issue1019)
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
85 |
cd .. |