##// END OF EJS Templates
tests: double escape \ in test-import-eol.t and test-mq-eol.t...
Gregory Szorc -
r41856:140b542b default
parent child Browse files
Show More
@@ -1,173 +1,173
1 $ cat > makepatch.py <<EOF
1 $ cat > makepatch.py <<EOF
2 > import sys
2 > import sys
3 > f = open(sys.argv[2], 'wb')
3 > f = open(sys.argv[2], 'wb')
4 > w = f.write
4 > w = f.write
5 > w(b'test message\n')
5 > w(b'test message\n')
6 > w(b'diff --git a/a b/a\n')
6 > w(b'diff --git a/a b/a\n')
7 > w(b'--- a/a\n')
7 > w(b'--- a/a\n')
8 > w(b'+++ b/a\n')
8 > w(b'+++ b/a\n')
9 > w(b'@@ -1,5 +1,5 @@\n')
9 > w(b'@@ -1,5 +1,5 @@\n')
10 > w(b' a\n')
10 > w(b' a\n')
11 > w(b'-bbb\r\n')
11 > w(b'-bbb\r\n')
12 > w(b'+yyyy\r\n')
12 > w(b'+yyyy\r\n')
13 > w(b' cc\r\n')
13 > w(b' cc\r\n')
14 > w({'empty:lf': b' \n',
14 > w({'empty:lf': b' \n',
15 > 'empty:crlf': b' \r\n',
15 > 'empty:crlf': b' \r\n',
16 > 'empty:stripped-lf': b'\n',
16 > 'empty:stripped-lf': b'\n',
17 > 'empty:stripped-crlf': b'\r\n'}[sys.argv[1]])
17 > 'empty:stripped-crlf': b'\r\n'}[sys.argv[1]])
18 > w(b' d\n')
18 > w(b' d\n')
19 > w(b'-e\n')
19 > w(b'-e\n')
20 > w(b'\\ No newline at end of file\n')
20 > w(b'\\\\ No newline at end of file\n')
21 > w(b'+z\r\n')
21 > w(b'+z\r\n')
22 > w(b'\\ No newline at end of file\r\n')
22 > w(b'\\\\ No newline at end of file\r\n')
23 > EOF
23 > EOF
24
24
25 $ hg init repo
25 $ hg init repo
26 $ cd repo
26 $ cd repo
27 $ echo '\.diff' > .hgignore
27 $ echo '\.diff' > .hgignore
28
28
29
29
30 Test different --eol values
30 Test different --eol values
31
31
32 $ "$PYTHON" -c 'open("a", "wb").write(b"a\nbbb\ncc\n\nd\ne")'
32 $ "$PYTHON" -c 'open("a", "wb").write(b"a\nbbb\ncc\n\nd\ne")'
33 $ hg ci -Am adda
33 $ hg ci -Am adda
34 adding .hgignore
34 adding .hgignore
35 adding a
35 adding a
36 $ "$PYTHON" ../makepatch.py empty:lf eol.diff
36 $ "$PYTHON" ../makepatch.py empty:lf eol.diff
37 $ "$PYTHON" ../makepatch.py empty:crlf eol-empty-crlf.diff
37 $ "$PYTHON" ../makepatch.py empty:crlf eol-empty-crlf.diff
38 $ "$PYTHON" ../makepatch.py empty:stripped-lf eol-empty-stripped-lf.diff
38 $ "$PYTHON" ../makepatch.py empty:stripped-lf eol-empty-stripped-lf.diff
39 $ "$PYTHON" ../makepatch.py empty:stripped-crlf eol-empty-stripped-crlf.diff
39 $ "$PYTHON" ../makepatch.py empty:stripped-crlf eol-empty-stripped-crlf.diff
40
40
41 invalid eol
41 invalid eol
42
42
43 $ hg --config patch.eol='LFCR' import eol.diff
43 $ hg --config patch.eol='LFCR' import eol.diff
44 applying eol.diff
44 applying eol.diff
45 abort: unsupported line endings type: LFCR
45 abort: unsupported line endings type: LFCR
46 [255]
46 [255]
47 $ hg revert -a
47 $ hg revert -a
48
48
49
49
50 force LF
50 force LF
51
51
52 $ hg --traceback --config patch.eol='LF' import eol.diff
52 $ hg --traceback --config patch.eol='LF' import eol.diff
53 applying eol.diff
53 applying eol.diff
54 $ hg id
54 $ hg id
55 9e4ef7b3d4af tip
55 9e4ef7b3d4af tip
56 $ cat a
56 $ cat a
57 a
57 a
58 yyyy
58 yyyy
59 cc
59 cc
60
60
61 d
61 d
62 e (no-eol)
62 e (no-eol)
63 $ hg st
63 $ hg st
64
64
65 (test empty-line variants: all of them should generate the same revision)
65 (test empty-line variants: all of them should generate the same revision)
66
66
67 $ hg up -qC 0
67 $ hg up -qC 0
68 $ hg --config patch.eol='LF' import eol-empty-crlf.diff
68 $ hg --config patch.eol='LF' import eol-empty-crlf.diff
69 applying eol-empty-crlf.diff
69 applying eol-empty-crlf.diff
70 $ hg id
70 $ hg id
71 9e4ef7b3d4af tip
71 9e4ef7b3d4af tip
72
72
73 $ hg up -qC 0
73 $ hg up -qC 0
74 $ hg --config patch.eol='LF' import eol-empty-stripped-lf.diff
74 $ hg --config patch.eol='LF' import eol-empty-stripped-lf.diff
75 applying eol-empty-stripped-lf.diff
75 applying eol-empty-stripped-lf.diff
76 $ hg id
76 $ hg id
77 9e4ef7b3d4af tip
77 9e4ef7b3d4af tip
78
78
79 $ hg up -qC 0
79 $ hg up -qC 0
80 $ hg --config patch.eol='LF' import eol-empty-stripped-crlf.diff
80 $ hg --config patch.eol='LF' import eol-empty-stripped-crlf.diff
81 applying eol-empty-stripped-crlf.diff
81 applying eol-empty-stripped-crlf.diff
82 $ hg id
82 $ hg id
83 9e4ef7b3d4af tip
83 9e4ef7b3d4af tip
84
84
85 force CRLF
85 force CRLF
86
86
87 $ hg up -C 0
87 $ hg up -C 0
88 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
88 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
89 $ hg --traceback --config patch.eol='CRLF' import eol.diff
89 $ hg --traceback --config patch.eol='CRLF' import eol.diff
90 applying eol.diff
90 applying eol.diff
91 $ cat a
91 $ cat a
92 a\r (esc)
92 a\r (esc)
93 yyyy\r (esc)
93 yyyy\r (esc)
94 cc\r (esc)
94 cc\r (esc)
95 \r (esc)
95 \r (esc)
96 d\r (esc)
96 d\r (esc)
97 e (no-eol)
97 e (no-eol)
98 $ hg st
98 $ hg st
99
99
100
100
101 auto EOL on LF file
101 auto EOL on LF file
102
102
103 $ hg up -C 0
103 $ hg up -C 0
104 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
104 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
105 $ hg --traceback --config patch.eol='auto' import eol.diff
105 $ hg --traceback --config patch.eol='auto' import eol.diff
106 applying eol.diff
106 applying eol.diff
107 $ cat a
107 $ cat a
108 a
108 a
109 yyyy
109 yyyy
110 cc
110 cc
111
111
112 d
112 d
113 e (no-eol)
113 e (no-eol)
114 $ hg st
114 $ hg st
115
115
116
116
117 auto EOL on CRLF file
117 auto EOL on CRLF file
118
118
119 $ "$PYTHON" -c 'open("a", "wb").write(b"a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
119 $ "$PYTHON" -c 'open("a", "wb").write(b"a\r\nbbb\r\ncc\r\n\r\nd\r\ne")'
120 $ hg commit -m 'switch EOLs in a'
120 $ hg commit -m 'switch EOLs in a'
121 $ hg --traceback --config patch.eol='auto' import eol.diff
121 $ hg --traceback --config patch.eol='auto' import eol.diff
122 applying eol.diff
122 applying eol.diff
123 $ cat a
123 $ cat a
124 a\r (esc)
124 a\r (esc)
125 yyyy\r (esc)
125 yyyy\r (esc)
126 cc\r (esc)
126 cc\r (esc)
127 \r (esc)
127 \r (esc)
128 d\r (esc)
128 d\r (esc)
129 e (no-eol)
129 e (no-eol)
130 $ hg st
130 $ hg st
131
131
132
132
133 auto EOL on new file or source without any EOL
133 auto EOL on new file or source without any EOL
134
134
135 $ "$PYTHON" -c 'open("noeol", "wb").write(b"noeol")'
135 $ "$PYTHON" -c 'open("noeol", "wb").write(b"noeol")'
136 $ hg add noeol
136 $ hg add noeol
137 $ hg commit -m 'add noeol'
137 $ hg commit -m 'add noeol'
138 $ "$PYTHON" -c 'open("noeol", "wb").write(b"noeol\r\nnoeol\n")'
138 $ "$PYTHON" -c 'open("noeol", "wb").write(b"noeol\r\nnoeol\n")'
139 $ "$PYTHON" -c 'open("neweol", "wb").write(b"neweol\nneweol\r\n")'
139 $ "$PYTHON" -c 'open("neweol", "wb").write(b"neweol\nneweol\r\n")'
140 $ hg add neweol
140 $ hg add neweol
141 $ hg diff --git > noeol.diff
141 $ hg diff --git > noeol.diff
142 $ hg revert --no-backup noeol neweol
142 $ hg revert --no-backup noeol neweol
143 $ rm neweol
143 $ rm neweol
144 $ hg --traceback --config patch.eol='auto' import -m noeol noeol.diff
144 $ hg --traceback --config patch.eol='auto' import -m noeol noeol.diff
145 applying noeol.diff
145 applying noeol.diff
146 $ cat noeol
146 $ cat noeol
147 noeol\r (esc)
147 noeol\r (esc)
148 noeol
148 noeol
149 $ cat neweol
149 $ cat neweol
150 neweol
150 neweol
151 neweol\r (esc)
151 neweol\r (esc)
152 $ hg st
152 $ hg st
153
153
154
154
155 Test --eol and binary patches
155 Test --eol and binary patches
156
156
157 $ "$PYTHON" -c 'open("b", "wb").write(b"a\x00\nb\r\nd")'
157 $ "$PYTHON" -c 'open("b", "wb").write(b"a\x00\nb\r\nd")'
158 $ hg ci -Am addb
158 $ hg ci -Am addb
159 adding b
159 adding b
160 $ "$PYTHON" -c 'open("b", "wb").write(b"a\x00\nc\r\nd")'
160 $ "$PYTHON" -c 'open("b", "wb").write(b"a\x00\nc\r\nd")'
161 $ hg diff --git > bin.diff
161 $ hg diff --git > bin.diff
162 $ hg revert --no-backup b
162 $ hg revert --no-backup b
163
163
164 binary patch with --eol
164 binary patch with --eol
165
165
166 $ hg import --config patch.eol='CRLF' -m changeb bin.diff
166 $ hg import --config patch.eol='CRLF' -m changeb bin.diff
167 applying bin.diff
167 applying bin.diff
168 $ cat b
168 $ cat b
169 a\x00 (esc)
169 a\x00 (esc)
170 c\r (esc)
170 c\r (esc)
171 d (no-eol)
171 d (no-eol)
172 $ hg st
172 $ hg st
173 $ cd ..
173 $ cd ..
@@ -1,215 +1,215
1
1
2 Test interactions between mq and patch.eol
2 Test interactions between mq and patch.eol
3
3
4
4
5 $ cat <<EOF >> $HGRCPATH
5 $ cat <<EOF >> $HGRCPATH
6 > [extensions]
6 > [extensions]
7 > mq =
7 > mq =
8 > [diff]
8 > [diff]
9 > nodates = 1
9 > nodates = 1
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(b'test message\n')
15 > w(b'test message\n')
16 > w(b'diff --git a/a b/a\n')
16 > w(b'diff --git a/a b/a\n')
17 > w(b'--- a/a\n')
17 > w(b'--- a/a\n')
18 > w(b'+++ b/a\n')
18 > w(b'+++ b/a\n')
19 > w(b'@@ -1,5 +1,5 @@\n')
19 > w(b'@@ -1,5 +1,5 @@\n')
20 > w(b' a\n')
20 > w(b' a\n')
21 > w(b'-b\r\n')
21 > w(b'-b\r\n')
22 > w(b'+y\r\n')
22 > w(b'+y\r\n')
23 > w(b' c\r\n')
23 > w(b' c\r\n')
24 > w(b' d\n')
24 > w(b' d\n')
25 > w(b'-e\n')
25 > w(b'-e\n')
26 > w(b'\\ No newline at end of file\n')
26 > w(b'\\\\ No newline at end of file\n')
27 > w(b'+z\r\n')
27 > w(b'+z\r\n')
28 > w(b'\\ 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 > try:
33 > try:
34 > stdout = sys.stdout.buffer
34 > stdout = sys.stdout.buffer
35 > except AttributeError:
35 > except AttributeError:
36 > stdout = sys.stdout
36 > stdout = sys.stdout
37 > for line in open(sys.argv[1], 'rb'):
37 > for line in open(sys.argv[1], 'rb'):
38 > line = line.replace(b'\r', b'<CR>')
38 > line = line.replace(b'\r', b'<CR>')
39 > line = line.replace(b'\n', b'<LF>')
39 > line = line.replace(b'\n', b'<LF>')
40 > stdout.write(line + b'\n')
40 > stdout.write(line + b'\n')
41 > EOF
41 > EOF
42
42
43 $ hg init repo
43 $ hg init repo
44 $ cd repo
44 $ cd repo
45 $ echo '\.diff' > .hgignore
45 $ echo '\.diff' > .hgignore
46 $ echo '\.rej' >> .hgignore
46 $ echo '\.rej' >> .hgignore
47
47
48
48
49 Test different --eol values
49 Test different --eol values
50
50
51 $ "$PYTHON" -c 'open("a", "wb").write(b"a\nb\nc\nd\ne")'
51 $ "$PYTHON" -c 'open("a", "wb").write(b"a\nb\nc\nd\ne")'
52 $ hg ci -Am adda
52 $ hg ci -Am adda
53 adding .hgignore
53 adding .hgignore
54 adding a
54 adding a
55 $ "$PYTHON" ../makepatch.py
55 $ "$PYTHON" ../makepatch.py
56 $ hg qimport eol.diff
56 $ hg qimport eol.diff
57 adding eol.diff to series file
57 adding eol.diff to series file
58
58
59 should fail in strict mode
59 should fail in strict mode
60
60
61 $ hg qpush
61 $ hg qpush
62 applying eol.diff
62 applying eol.diff
63 patching file a
63 patching file a
64 Hunk #1 FAILED at 0
64 Hunk #1 FAILED at 0
65 1 out of 1 hunks FAILED -- saving rejects to file a.rej
65 1 out of 1 hunks FAILED -- saving rejects to file a.rej
66 patch failed, unable to continue (try -v)
66 patch failed, unable to continue (try -v)
67 patch failed, rejects left in working directory
67 patch failed, rejects left in working directory
68 errors during apply, please fix and qrefresh eol.diff
68 errors during apply, please fix and qrefresh eol.diff
69 [2]
69 [2]
70 $ hg qpop
70 $ hg qpop
71 popping eol.diff
71 popping eol.diff
72 patch queue now empty
72 patch queue now empty
73
73
74 invalid eol
74 invalid eol
75
75
76 $ hg --config patch.eol='LFCR' qpush
76 $ hg --config patch.eol='LFCR' qpush
77 applying eol.diff
77 applying eol.diff
78 patch failed, unable to continue (try -v)
78 patch failed, unable to continue (try -v)
79 patch failed, rejects left in working directory
79 patch failed, rejects left in working directory
80 errors during apply, please fix and qrefresh eol.diff
80 errors during apply, please fix and qrefresh eol.diff
81 [2]
81 [2]
82 $ hg qpop
82 $ hg qpop
83 popping eol.diff
83 popping eol.diff
84 patch queue now empty
84 patch queue now empty
85
85
86 force LF
86 force LF
87
87
88 $ hg --config patch.eol='CRLF' qpush
88 $ hg --config patch.eol='CRLF' qpush
89 applying eol.diff
89 applying eol.diff
90 now at: eol.diff
90 now at: eol.diff
91 $ hg qrefresh
91 $ hg qrefresh
92 $ "$PYTHON" ../cateol.py .hg/patches/eol.diff
92 $ "$PYTHON" ../cateol.py .hg/patches/eol.diff
93 # HG changeset patch<LF>
93 # HG changeset patch<LF>
94 # Parent 0d0bf99a8b7a3842c6f8ef09e34f69156c4bd9d0<LF>
94 # Parent 0d0bf99a8b7a3842c6f8ef09e34f69156c4bd9d0<LF>
95 test message<LF>
95 test message<LF>
96 <LF>
96 <LF>
97 diff -r 0d0bf99a8b7a a<LF>
97 diff -r 0d0bf99a8b7a a<LF>
98 --- a/a<LF>
98 --- a/a<LF>
99 +++ b/a<LF>
99 +++ b/a<LF>
100 @@ -1,5 +1,5 @@<LF>
100 @@ -1,5 +1,5 @@<LF>
101 -a<LF>
101 -a<LF>
102 -b<LF>
102 -b<LF>
103 -c<LF>
103 -c<LF>
104 -d<LF>
104 -d<LF>
105 -e<LF>
105 -e<LF>
106 \ No newline at end of file<LF>
106 \ No newline at end of file<LF>
107 +a<CR><LF>
107 +a<CR><LF>
108 +y<CR><LF>
108 +y<CR><LF>
109 +c<CR><LF>
109 +c<CR><LF>
110 +d<CR><LF>
110 +d<CR><LF>
111 +z<LF>
111 +z<LF>
112 \ No newline at end of file<LF>
112 \ No newline at end of file<LF>
113 $ "$PYTHON" ../cateol.py a
113 $ "$PYTHON" ../cateol.py a
114 a<CR><LF>
114 a<CR><LF>
115 y<CR><LF>
115 y<CR><LF>
116 c<CR><LF>
116 c<CR><LF>
117 d<CR><LF>
117 d<CR><LF>
118 z
118 z
119 $ hg qpop
119 $ hg qpop
120 popping eol.diff
120 popping eol.diff
121 patch queue now empty
121 patch queue now empty
122
122
123 push again forcing LF and compare revisions
123 push again forcing LF and compare revisions
124
124
125 $ hg --config patch.eol='CRLF' qpush
125 $ hg --config patch.eol='CRLF' qpush
126 applying eol.diff
126 applying eol.diff
127 now at: eol.diff
127 now at: eol.diff
128 $ "$PYTHON" ../cateol.py a
128 $ "$PYTHON" ../cateol.py a
129 a<CR><LF>
129 a<CR><LF>
130 y<CR><LF>
130 y<CR><LF>
131 c<CR><LF>
131 c<CR><LF>
132 d<CR><LF>
132 d<CR><LF>
133 z
133 z
134 $ hg qpop
134 $ hg qpop
135 popping eol.diff
135 popping eol.diff
136 patch queue now empty
136 patch queue now empty
137
137
138 push again without LF and compare revisions
138 push again without LF and compare revisions
139
139
140 $ hg qpush
140 $ hg qpush
141 applying eol.diff
141 applying eol.diff
142 now at: eol.diff
142 now at: eol.diff
143 $ "$PYTHON" ../cateol.py a
143 $ "$PYTHON" ../cateol.py a
144 a<CR><LF>
144 a<CR><LF>
145 y<CR><LF>
145 y<CR><LF>
146 c<CR><LF>
146 c<CR><LF>
147 d<CR><LF>
147 d<CR><LF>
148 z
148 z
149 $ hg qpop
149 $ hg qpop
150 popping eol.diff
150 popping eol.diff
151 patch queue now empty
151 patch queue now empty
152 $ cd ..
152 $ cd ..
153
153
154
154
155 Test .rej file EOL are left unchanged
155 Test .rej file EOL are left unchanged
156
156
157 $ hg init testeol
157 $ hg init testeol
158 $ cd testeol
158 $ cd testeol
159 $ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n2\r\n3\r\n4')"
159 $ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n2\r\n3\r\n4')"
160 $ hg ci -Am adda
160 $ hg ci -Am adda
161 adding a
161 adding a
162 $ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n2\r\n33\r\n4')"
162 $ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n2\r\n33\r\n4')"
163 $ hg qnew patch1
163 $ hg qnew patch1
164 $ hg qpop
164 $ hg qpop
165 popping patch1
165 popping patch1
166 patch queue now empty
166 patch queue now empty
167 $ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n22\r\n33\r\n4')"
167 $ "$PYTHON" -c "open('a', 'wb').write(b'1\r\n22\r\n33\r\n4')"
168 $ hg ci -m changea
168 $ hg ci -m changea
169
169
170 $ hg --config 'patch.eol=LF' qpush
170 $ hg --config 'patch.eol=LF' qpush
171 applying patch1
171 applying patch1
172 patching file a
172 patching file a
173 Hunk #1 FAILED at 0
173 Hunk #1 FAILED at 0
174 1 out of 1 hunks FAILED -- saving rejects to file a.rej
174 1 out of 1 hunks FAILED -- saving rejects to file a.rej
175 patch failed, unable to continue (try -v)
175 patch failed, unable to continue (try -v)
176 patch failed, rejects left in working directory
176 patch failed, rejects left in working directory
177 errors during apply, please fix and qrefresh patch1
177 errors during apply, please fix and qrefresh patch1
178 [2]
178 [2]
179 $ hg qpop
179 $ hg qpop
180 popping patch1
180 popping patch1
181 patch queue now empty
181 patch queue now empty
182 $ cat a.rej
182 $ cat a.rej
183 --- a
183 --- a
184 +++ a
184 +++ a
185 @@ -1,4 +1,4 @@
185 @@ -1,4 +1,4 @@
186 1\r (esc)
186 1\r (esc)
187 2\r (esc)
187 2\r (esc)
188 -3\r (esc)
188 -3\r (esc)
189 +33\r (esc)
189 +33\r (esc)
190 4
190 4
191 \ No newline at end of file
191 \ No newline at end of file
192
192
193 $ hg --config 'patch.eol=auto' qpush
193 $ hg --config 'patch.eol=auto' qpush
194 applying patch1
194 applying patch1
195 patching file a
195 patching file a
196 Hunk #1 FAILED at 0
196 Hunk #1 FAILED at 0
197 1 out of 1 hunks FAILED -- saving rejects to file a.rej
197 1 out of 1 hunks FAILED -- saving rejects to file a.rej
198 patch failed, unable to continue (try -v)
198 patch failed, unable to continue (try -v)
199 patch failed, rejects left in working directory
199 patch failed, rejects left in working directory
200 errors during apply, please fix and qrefresh patch1
200 errors during apply, please fix and qrefresh patch1
201 [2]
201 [2]
202 $ hg qpop
202 $ hg qpop
203 popping patch1
203 popping patch1
204 patch queue now empty
204 patch queue now empty
205 $ cat a.rej
205 $ cat a.rej
206 --- a
206 --- a
207 +++ a
207 +++ a
208 @@ -1,4 +1,4 @@
208 @@ -1,4 +1,4 @@
209 1\r (esc)
209 1\r (esc)
210 2\r (esc)
210 2\r (esc)
211 -3\r (esc)
211 -3\r (esc)
212 +33\r (esc)
212 +33\r (esc)
213 4
213 4
214 \ No newline at end of file
214 \ No newline at end of file
215 $ cd ..
215 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now