equal
deleted
inserted
replaced
10 > EOF |
10 > EOF |
11 |
11 |
12 $ cat > makepatch.py <<EOF |
12 $ cat > makepatch.py <<EOF |
13 > f = open('eol.diff', 'wb') |
13 > f = open('eol.diff', 'wb') |
14 > w = f.write |
14 > w = f.write |
15 > w('test message\n') |
15 > w(b'test message\n') |
16 > w('diff --git a/a b/a\n') |
16 > w(b'diff --git a/a b/a\n') |
17 > w('--- a/a\n') |
17 > w(b'--- a/a\n') |
18 > w('+++ b/a\n') |
18 > w(b'+++ b/a\n') |
19 > w('@@ -1,5 +1,5 @@\n') |
19 > w(b'@@ -1,5 +1,5 @@\n') |
20 > w(' a\n') |
20 > w(b' a\n') |
21 > w('-b\r\n') |
21 > w(b'-b\r\n') |
22 > w('+y\r\n') |
22 > w(b'+y\r\n') |
23 > w(' c\r\n') |
23 > w(b' c\r\n') |
24 > w(' d\n') |
24 > w(b' d\n') |
25 > w('-e\n') |
25 > w(b'-e\n') |
26 > w('\ No newline at end of file\n') |
26 > w(b'\ No newline at end of file\n') |
27 > w('+z\r\n') |
27 > w(b'+z\r\n') |
28 > w('\ No newline at end of file\r\n') |
28 > w(b'\ No newline at end of file\r\n') |
29 > EOF |
29 > EOF |
30 |
30 |
31 $ cat > cateol.py <<EOF |
31 $ cat > cateol.py <<EOF |
32 > import sys |
32 > import sys |
33 > for line in open(sys.argv[1], 'rb'): |
33 > for line in open(sys.argv[1], 'rb'): |
34 > line = line.replace('\r', '<CR>') |
34 > line = line.replace(b'\r', b'<CR>') |
35 > line = line.replace('\n', '<LF>') |
35 > line = line.replace(b'\n', b'<LF>') |
36 > print(line) |
36 > print(line) |
37 > EOF |
37 > EOF |
38 |
38 |
39 $ hg init repo |
39 $ hg init repo |
40 $ cd repo |
40 $ cd repo |
42 $ echo '\.rej' >> .hgignore |
42 $ echo '\.rej' >> .hgignore |
43 |
43 |
44 |
44 |
45 Test different --eol values |
45 Test different --eol values |
46 |
46 |
47 $ $PYTHON -c 'open("a", "wb").write("a\nb\nc\nd\ne")' |
47 $ $PYTHON -c 'open("a", "wb").write(b"a\nb\nc\nd\ne")' |
48 $ hg ci -Am adda |
48 $ hg ci -Am adda |
49 adding .hgignore |
49 adding .hgignore |
50 adding a |
50 adding a |
51 $ $PYTHON ../makepatch.py |
51 $ $PYTHON ../makepatch.py |
52 $ hg qimport eol.diff |
52 $ hg qimport eol.diff |
150 |
150 |
151 Test .rej file EOL are left unchanged |
151 Test .rej file EOL are left unchanged |
152 |
152 |
153 $ hg init testeol |
153 $ hg init testeol |
154 $ cd testeol |
154 $ cd testeol |
155 $ $PYTHON -c "open('a', 'wb').write('1\r\n2\r\n3\r\n4')" |
155 $ $PYTHON -c "open('a', 'wb').write(b'1\r\n2\r\n3\r\n4')" |
156 $ hg ci -Am adda |
156 $ hg ci -Am adda |
157 adding a |
157 adding a |
158 $ $PYTHON -c "open('a', 'wb').write('1\r\n2\r\n33\r\n4')" |
158 $ $PYTHON -c "open('a', 'wb').write(b'1\r\n2\r\n33\r\n4')" |
159 $ hg qnew patch1 |
159 $ hg qnew patch1 |
160 $ hg qpop |
160 $ hg qpop |
161 popping patch1 |
161 popping patch1 |
162 patch queue now empty |
162 patch queue now empty |
163 $ $PYTHON -c "open('a', 'wb').write('1\r\n22\r\n33\r\n4')" |
163 $ $PYTHON -c "open('a', 'wb').write(b'1\r\n22\r\n33\r\n4')" |
164 $ hg ci -m changea |
164 $ hg ci -m changea |
165 |
165 |
166 $ hg --config 'patch.eol=LF' qpush |
166 $ hg --config 'patch.eol=LF' qpush |
167 applying patch1 |
167 applying patch1 |
168 patching file a |
168 patching file a |