equal
deleted
inserted
replaced
1 $ cat > makepatch.py <<EOF |
1 $ cat > makepatch.py <<EOF |
2 > f = file('eol.diff', 'wb') |
2 > f = open('eol.diff', 'wb') |
3 > w = f.write |
3 > w = f.write |
4 > w('test message\n') |
4 > w(b'test message\n') |
5 > w('diff --git a/a b/a\n') |
5 > w(b'diff --git a/a b/a\n') |
6 > w('--- a/a\n') |
6 > w(b'--- a/a\n') |
7 > w('+++ b/a\n') |
7 > w(b'+++ b/a\n') |
8 > w('@@ -1,5 +1,5 @@\n') |
8 > w(b'@@ -1,5 +1,5 @@\n') |
9 > w(' a\n') |
9 > w(b' a\n') |
10 > w('-bbb\r\n') |
10 > w(b'-bbb\r\n') |
11 > w('+yyyy\r\n') |
11 > w(b'+yyyy\r\n') |
12 > w(' cc\r\n') |
12 > w(b' cc\r\n') |
13 > w(' \n') |
13 > w(b' \n') |
14 > w(' d\n') |
14 > w(b' d\n') |
15 > w('-e\n') |
15 > w(b'-e\n') |
16 > w('\ No newline at end of file\n') |
16 > w(b'\ No newline at end of file\n') |
17 > w('+z\r\n') |
17 > w(b'+z\r\n') |
18 > w('\ No newline at end of file\r\n') |
18 > w(b'\ No newline at end of file\r\n') |
19 > EOF |
19 > EOF |
20 |
20 |
21 $ hg init repo |
21 $ hg init repo |
22 $ cd repo |
22 $ cd repo |
23 $ echo '\.diff' > .hgignore |
23 $ echo '\.diff' > .hgignore |
24 |
24 |
25 |
25 |
26 Test different --eol values |
26 Test different --eol values |
27 |
27 |
28 $ $PYTHON -c 'file("a", "wb").write("a\nbbb\ncc\n\nd\ne")' |
28 $ $PYTHON -c 'open("a", "wb").write(b"a\nbbb\ncc\n\nd\ne")' |
29 $ hg ci -Am adda |
29 $ hg ci -Am adda |
30 adding .hgignore |
30 adding .hgignore |
31 adding a |
31 adding a |
32 $ $PYTHON ../makepatch.py |
32 $ $PYTHON ../makepatch.py |
33 |
33 |
87 $ hg st |
87 $ hg st |
88 |
88 |
89 |
89 |
90 auto EOL on CRLF file |
90 auto EOL on CRLF file |
91 |
91 |
92 $ $PYTHON -c 'file("a", "wb").write("a\r\nbbb\r\ncc\r\n\r\nd\r\ne")' |
92 $ $PYTHON -c 'open("a", "wb").write(b"a\r\nbbb\r\ncc\r\n\r\nd\r\ne")' |
93 $ hg commit -m 'switch EOLs in a' |
93 $ hg commit -m 'switch EOLs in a' |
94 $ hg --traceback --config patch.eol='auto' import eol.diff |
94 $ hg --traceback --config patch.eol='auto' import eol.diff |
95 applying eol.diff |
95 applying eol.diff |
96 $ cat a |
96 $ cat a |
97 a\r (esc) |
97 a\r (esc) |
103 $ hg st |
103 $ hg st |
104 |
104 |
105 |
105 |
106 auto EOL on new file or source without any EOL |
106 auto EOL on new file or source without any EOL |
107 |
107 |
108 $ $PYTHON -c 'file("noeol", "wb").write("noeol")' |
108 $ $PYTHON -c 'open("noeol", "wb").write(b"noeol")' |
109 $ hg add noeol |
109 $ hg add noeol |
110 $ hg commit -m 'add noeol' |
110 $ hg commit -m 'add noeol' |
111 $ $PYTHON -c 'file("noeol", "wb").write("noeol\r\nnoeol\n")' |
111 $ $PYTHON -c 'open("noeol", "wb").write(b"noeol\r\nnoeol\n")' |
112 $ $PYTHON -c 'file("neweol", "wb").write("neweol\nneweol\r\n")' |
112 $ $PYTHON -c 'open("neweol", "wb").write(b"neweol\nneweol\r\n")' |
113 $ hg add neweol |
113 $ hg add neweol |
114 $ hg diff --git > noeol.diff |
114 $ hg diff --git > noeol.diff |
115 $ hg revert --no-backup noeol neweol |
115 $ hg revert --no-backup noeol neweol |
116 $ rm neweol |
116 $ rm neweol |
117 $ hg --traceback --config patch.eol='auto' import -m noeol noeol.diff |
117 $ hg --traceback --config patch.eol='auto' import -m noeol noeol.diff |
125 $ hg st |
125 $ hg st |
126 |
126 |
127 |
127 |
128 Test --eol and binary patches |
128 Test --eol and binary patches |
129 |
129 |
130 $ $PYTHON -c 'file("b", "wb").write("a\x00\nb\r\nd")' |
130 $ $PYTHON -c 'open("b", "wb").write(b"a\x00\nb\r\nd")' |
131 $ hg ci -Am addb |
131 $ hg ci -Am addb |
132 adding b |
132 adding b |
133 $ $PYTHON -c 'file("b", "wb").write("a\x00\nc\r\nd")' |
133 $ $PYTHON -c 'open("b", "wb").write(b"a\x00\nc\r\nd")' |
134 $ hg diff --git > bin.diff |
134 $ hg diff --git > bin.diff |
135 $ hg revert --no-backup b |
135 $ hg revert --no-backup b |
136 |
136 |
137 binary patch with --eol |
137 binary patch with --eol |
138 |
138 |