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