##// END OF EJS Templates
tests: write directly to stdout to avoid b'' prefixes...
Gregory Szorc -
r41360:84707d9e default
parent child Browse files
Show More
@@ -1,211 +1,215 b''
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:
34 > stdout = sys.stdout.buffer
35 > except AttributeError:
36 > stdout = sys.stdout
33 > for line in open(sys.argv[1], 'rb'):
37 > for line in open(sys.argv[1], 'rb'):
34 > line = line.replace(b'\r', b'<CR>')
38 > line = line.replace(b'\r', b'<CR>')
35 > line = line.replace(b'\n', b'<LF>')
39 > line = line.replace(b'\n', b'<LF>')
36 > print(line)
40 > stdout.write(line + b'\n')
37 > EOF
41 > EOF
38
42
39 $ hg init repo
43 $ hg init repo
40 $ cd repo
44 $ cd repo
41 $ echo '\.diff' > .hgignore
45 $ echo '\.diff' > .hgignore
42 $ echo '\.rej' >> .hgignore
46 $ echo '\.rej' >> .hgignore
43
47
44
48
45 Test different --eol values
49 Test different --eol values
46
50
47 $ "$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")'
48 $ hg ci -Am adda
52 $ hg ci -Am adda
49 adding .hgignore
53 adding .hgignore
50 adding a
54 adding a
51 $ "$PYTHON" ../makepatch.py
55 $ "$PYTHON" ../makepatch.py
52 $ hg qimport eol.diff
56 $ hg qimport eol.diff
53 adding eol.diff to series file
57 adding eol.diff to series file
54
58
55 should fail in strict mode
59 should fail in strict mode
56
60
57 $ hg qpush
61 $ hg qpush
58 applying eol.diff
62 applying eol.diff
59 patching file a
63 patching file a
60 Hunk #1 FAILED at 0
64 Hunk #1 FAILED at 0
61 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
62 patch failed, unable to continue (try -v)
66 patch failed, unable to continue (try -v)
63 patch failed, rejects left in working directory
67 patch failed, rejects left in working directory
64 errors during apply, please fix and qrefresh eol.diff
68 errors during apply, please fix and qrefresh eol.diff
65 [2]
69 [2]
66 $ hg qpop
70 $ hg qpop
67 popping eol.diff
71 popping eol.diff
68 patch queue now empty
72 patch queue now empty
69
73
70 invalid eol
74 invalid eol
71
75
72 $ hg --config patch.eol='LFCR' qpush
76 $ hg --config patch.eol='LFCR' qpush
73 applying eol.diff
77 applying eol.diff
74 patch failed, unable to continue (try -v)
78 patch failed, unable to continue (try -v)
75 patch failed, rejects left in working directory
79 patch failed, rejects left in working directory
76 errors during apply, please fix and qrefresh eol.diff
80 errors during apply, please fix and qrefresh eol.diff
77 [2]
81 [2]
78 $ hg qpop
82 $ hg qpop
79 popping eol.diff
83 popping eol.diff
80 patch queue now empty
84 patch queue now empty
81
85
82 force LF
86 force LF
83
87
84 $ hg --config patch.eol='CRLF' qpush
88 $ hg --config patch.eol='CRLF' qpush
85 applying eol.diff
89 applying eol.diff
86 now at: eol.diff
90 now at: eol.diff
87 $ hg qrefresh
91 $ hg qrefresh
88 $ "$PYTHON" ../cateol.py .hg/patches/eol.diff
92 $ "$PYTHON" ../cateol.py .hg/patches/eol.diff
89 # HG changeset patch<LF>
93 # HG changeset patch<LF>
90 # Parent 0d0bf99a8b7a3842c6f8ef09e34f69156c4bd9d0<LF>
94 # Parent 0d0bf99a8b7a3842c6f8ef09e34f69156c4bd9d0<LF>
91 test message<LF>
95 test message<LF>
92 <LF>
96 <LF>
93 diff -r 0d0bf99a8b7a a<LF>
97 diff -r 0d0bf99a8b7a a<LF>
94 --- a/a<LF>
98 --- a/a<LF>
95 +++ b/a<LF>
99 +++ b/a<LF>
96 @@ -1,5 +1,5 @@<LF>
100 @@ -1,5 +1,5 @@<LF>
97 -a<LF>
101 -a<LF>
98 -b<LF>
102 -b<LF>
99 -c<LF>
103 -c<LF>
100 -d<LF>
104 -d<LF>
101 -e<LF>
105 -e<LF>
102 \ No newline at end of file<LF>
106 \ No newline at end of file<LF>
103 +a<CR><LF>
107 +a<CR><LF>
104 +y<CR><LF>
108 +y<CR><LF>
105 +c<CR><LF>
109 +c<CR><LF>
106 +d<CR><LF>
110 +d<CR><LF>
107 +z<LF>
111 +z<LF>
108 \ No newline at end of file<LF>
112 \ No newline at end of file<LF>
109 $ "$PYTHON" ../cateol.py a
113 $ "$PYTHON" ../cateol.py a
110 a<CR><LF>
114 a<CR><LF>
111 y<CR><LF>
115 y<CR><LF>
112 c<CR><LF>
116 c<CR><LF>
113 d<CR><LF>
117 d<CR><LF>
114 z
118 z
115 $ hg qpop
119 $ hg qpop
116 popping eol.diff
120 popping eol.diff
117 patch queue now empty
121 patch queue now empty
118
122
119 push again forcing LF and compare revisions
123 push again forcing LF and compare revisions
120
124
121 $ hg --config patch.eol='CRLF' qpush
125 $ hg --config patch.eol='CRLF' qpush
122 applying eol.diff
126 applying eol.diff
123 now at: eol.diff
127 now at: eol.diff
124 $ "$PYTHON" ../cateol.py a
128 $ "$PYTHON" ../cateol.py a
125 a<CR><LF>
129 a<CR><LF>
126 y<CR><LF>
130 y<CR><LF>
127 c<CR><LF>
131 c<CR><LF>
128 d<CR><LF>
132 d<CR><LF>
129 z
133 z
130 $ hg qpop
134 $ hg qpop
131 popping eol.diff
135 popping eol.diff
132 patch queue now empty
136 patch queue now empty
133
137
134 push again without LF and compare revisions
138 push again without LF and compare revisions
135
139
136 $ hg qpush
140 $ hg qpush
137 applying eol.diff
141 applying eol.diff
138 now at: eol.diff
142 now at: eol.diff
139 $ "$PYTHON" ../cateol.py a
143 $ "$PYTHON" ../cateol.py a
140 a<CR><LF>
144 a<CR><LF>
141 y<CR><LF>
145 y<CR><LF>
142 c<CR><LF>
146 c<CR><LF>
143 d<CR><LF>
147 d<CR><LF>
144 z
148 z
145 $ hg qpop
149 $ hg qpop
146 popping eol.diff
150 popping eol.diff
147 patch queue now empty
151 patch queue now empty
148 $ cd ..
152 $ cd ..
149
153
150
154
151 Test .rej file EOL are left unchanged
155 Test .rej file EOL are left unchanged
152
156
153 $ hg init testeol
157 $ hg init testeol
154 $ cd testeol
158 $ cd testeol
155 $ "$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')"
156 $ hg ci -Am adda
160 $ hg ci -Am adda
157 adding a
161 adding a
158 $ "$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')"
159 $ hg qnew patch1
163 $ hg qnew patch1
160 $ hg qpop
164 $ hg qpop
161 popping patch1
165 popping patch1
162 patch queue now empty
166 patch queue now empty
163 $ "$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')"
164 $ hg ci -m changea
168 $ hg ci -m changea
165
169
166 $ hg --config 'patch.eol=LF' qpush
170 $ hg --config 'patch.eol=LF' qpush
167 applying patch1
171 applying patch1
168 patching file a
172 patching file a
169 Hunk #1 FAILED at 0
173 Hunk #1 FAILED at 0
170 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
171 patch failed, unable to continue (try -v)
175 patch failed, unable to continue (try -v)
172 patch failed, rejects left in working directory
176 patch failed, rejects left in working directory
173 errors during apply, please fix and qrefresh patch1
177 errors during apply, please fix and qrefresh patch1
174 [2]
178 [2]
175 $ hg qpop
179 $ hg qpop
176 popping patch1
180 popping patch1
177 patch queue now empty
181 patch queue now empty
178 $ cat a.rej
182 $ cat a.rej
179 --- a
183 --- a
180 +++ a
184 +++ a
181 @@ -1,4 +1,4 @@
185 @@ -1,4 +1,4 @@
182 1\r (esc)
186 1\r (esc)
183 2\r (esc)
187 2\r (esc)
184 -3\r (esc)
188 -3\r (esc)
185 +33\r (esc)
189 +33\r (esc)
186 4
190 4
187 \ No newline at end of file
191 \ No newline at end of file
188
192
189 $ hg --config 'patch.eol=auto' qpush
193 $ hg --config 'patch.eol=auto' qpush
190 applying patch1
194 applying patch1
191 patching file a
195 patching file a
192 Hunk #1 FAILED at 0
196 Hunk #1 FAILED at 0
193 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
194 patch failed, unable to continue (try -v)
198 patch failed, unable to continue (try -v)
195 patch failed, rejects left in working directory
199 patch failed, rejects left in working directory
196 errors during apply, please fix and qrefresh patch1
200 errors during apply, please fix and qrefresh patch1
197 [2]
201 [2]
198 $ hg qpop
202 $ hg qpop
199 popping patch1
203 popping patch1
200 patch queue now empty
204 patch queue now empty
201 $ cat a.rej
205 $ cat a.rej
202 --- a
206 --- a
203 +++ a
207 +++ a
204 @@ -1,4 +1,4 @@
208 @@ -1,4 +1,4 @@
205 1\r (esc)
209 1\r (esc)
206 2\r (esc)
210 2\r (esc)
207 -3\r (esc)
211 -3\r (esc)
208 +33\r (esc)
212 +33\r (esc)
209 4
213 4
210 \ No newline at end of file
214 \ No newline at end of file
211 $ cd ..
215 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now