##// END OF EJS Templates
py3: suppress output from f.write() function class...
Pulkit Goyal -
r37387:22f19da5 default
parent child Browse files
Show More
@@ -1,458 +1,458 b''
1 $ hg init repo
1 $ hg init repo
2 $ cd repo
2 $ cd repo
3 $ cat > a <<EOF
3 $ cat > a <<EOF
4 > c
4 > c
5 > c
5 > c
6 > a
6 > a
7 > a
7 > a
8 > b
8 > b
9 > a
9 > a
10 > a
10 > a
11 > c
11 > c
12 > c
12 > c
13 > EOF
13 > EOF
14 $ hg ci -Am adda
14 $ hg ci -Am adda
15 adding a
15 adding a
16
16
17 $ cat > a <<EOF
17 $ cat > a <<EOF
18 > c
18 > c
19 > c
19 > c
20 > a
20 > a
21 > a
21 > a
22 > dd
22 > dd
23 > a
23 > a
24 > a
24 > a
25 > c
25 > c
26 > c
26 > c
27 > EOF
27 > EOF
28
28
29 default context
29 default context
30
30
31 $ hg diff --nodates
31 $ hg diff --nodates
32 diff -r cf9f4ba66af2 a
32 diff -r cf9f4ba66af2 a
33 --- a/a
33 --- a/a
34 +++ b/a
34 +++ b/a
35 @@ -2,7 +2,7 @@
35 @@ -2,7 +2,7 @@
36 c
36 c
37 a
37 a
38 a
38 a
39 -b
39 -b
40 +dd
40 +dd
41 a
41 a
42 a
42 a
43 c
43 c
44
44
45 invalid --unified
45 invalid --unified
46
46
47 $ hg diff --nodates -U foo
47 $ hg diff --nodates -U foo
48 abort: diff context lines count must be an integer, not 'foo'
48 abort: diff context lines count must be an integer, not 'foo'
49 [255]
49 [255]
50
50
51
51
52 $ hg diff --nodates -U 2
52 $ hg diff --nodates -U 2
53 diff -r cf9f4ba66af2 a
53 diff -r cf9f4ba66af2 a
54 --- a/a
54 --- a/a
55 +++ b/a
55 +++ b/a
56 @@ -3,5 +3,5 @@
56 @@ -3,5 +3,5 @@
57 a
57 a
58 a
58 a
59 -b
59 -b
60 +dd
60 +dd
61 a
61 a
62 a
62 a
63
63
64 $ hg --config diff.unified=2 diff --nodates
64 $ hg --config diff.unified=2 diff --nodates
65 diff -r cf9f4ba66af2 a
65 diff -r cf9f4ba66af2 a
66 --- a/a
66 --- a/a
67 +++ b/a
67 +++ b/a
68 @@ -3,5 +3,5 @@
68 @@ -3,5 +3,5 @@
69 a
69 a
70 a
70 a
71 -b
71 -b
72 +dd
72 +dd
73 a
73 a
74 a
74 a
75
75
76 $ hg diff --nodates -U 1
76 $ hg diff --nodates -U 1
77 diff -r cf9f4ba66af2 a
77 diff -r cf9f4ba66af2 a
78 --- a/a
78 --- a/a
79 +++ b/a
79 +++ b/a
80 @@ -4,3 +4,3 @@
80 @@ -4,3 +4,3 @@
81 a
81 a
82 -b
82 -b
83 +dd
83 +dd
84 a
84 a
85
85
86 invalid diff.unified
86 invalid diff.unified
87
87
88 $ hg --config diff.unified=foo diff --nodates
88 $ hg --config diff.unified=foo diff --nodates
89 abort: diff context lines count must be an integer, not 'foo'
89 abort: diff context lines count must be an integer, not 'foo'
90 [255]
90 [255]
91
91
92 noprefix config and option
92 noprefix config and option
93
93
94 $ hg --config diff.noprefix=True diff --nodates
94 $ hg --config diff.noprefix=True diff --nodates
95 diff -r cf9f4ba66af2 a
95 diff -r cf9f4ba66af2 a
96 --- a
96 --- a
97 +++ a
97 +++ a
98 @@ -2,7 +2,7 @@
98 @@ -2,7 +2,7 @@
99 c
99 c
100 a
100 a
101 a
101 a
102 -b
102 -b
103 +dd
103 +dd
104 a
104 a
105 a
105 a
106 c
106 c
107 $ hg diff --noprefix --nodates
107 $ hg diff --noprefix --nodates
108 diff -r cf9f4ba66af2 a
108 diff -r cf9f4ba66af2 a
109 --- a
109 --- a
110 +++ a
110 +++ a
111 @@ -2,7 +2,7 @@
111 @@ -2,7 +2,7 @@
112 c
112 c
113 a
113 a
114 a
114 a
115 -b
115 -b
116 +dd
116 +dd
117 a
117 a
118 a
118 a
119 c
119 c
120
120
121 noprefix config disabled in plain mode, but option still enabled
121 noprefix config disabled in plain mode, but option still enabled
122
122
123 $ HGPLAIN=1 hg --config diff.noprefix=True diff --nodates
123 $ HGPLAIN=1 hg --config diff.noprefix=True diff --nodates
124 diff -r cf9f4ba66af2 a
124 diff -r cf9f4ba66af2 a
125 --- a/a
125 --- a/a
126 +++ b/a
126 +++ b/a
127 @@ -2,7 +2,7 @@
127 @@ -2,7 +2,7 @@
128 c
128 c
129 a
129 a
130 a
130 a
131 -b
131 -b
132 +dd
132 +dd
133 a
133 a
134 a
134 a
135 c
135 c
136 $ HGPLAIN=1 hg diff --noprefix --nodates
136 $ HGPLAIN=1 hg diff --noprefix --nodates
137 diff -r cf9f4ba66af2 a
137 diff -r cf9f4ba66af2 a
138 --- a
138 --- a
139 +++ a
139 +++ a
140 @@ -2,7 +2,7 @@
140 @@ -2,7 +2,7 @@
141 c
141 c
142 a
142 a
143 a
143 a
144 -b
144 -b
145 +dd
145 +dd
146 a
146 a
147 a
147 a
148 c
148 c
149
149
150 $ cd ..
150 $ cd ..
151
151
152
152
153 0 lines of context hunk header matches gnu diff hunk header
153 0 lines of context hunk header matches gnu diff hunk header
154
154
155 $ hg init diffzero
155 $ hg init diffzero
156 $ cd diffzero
156 $ cd diffzero
157 $ cat > f1 << EOF
157 $ cat > f1 << EOF
158 > c2
158 > c2
159 > c4
159 > c4
160 > c5
160 > c5
161 > EOF
161 > EOF
162 $ hg commit -Am0
162 $ hg commit -Am0
163 adding f1
163 adding f1
164
164
165 $ cat > f2 << EOF
165 $ cat > f2 << EOF
166 > c1
166 > c1
167 > c2
167 > c2
168 > c3
168 > c3
169 > c4
169 > c4
170 > EOF
170 > EOF
171 $ mv f2 f1
171 $ mv f2 f1
172 $ hg diff -U0 --nodates
172 $ hg diff -U0 --nodates
173 diff -r 55d8ff78db23 f1
173 diff -r 55d8ff78db23 f1
174 --- a/f1
174 --- a/f1
175 +++ b/f1
175 +++ b/f1
176 @@ -0,0 +1,1 @@
176 @@ -0,0 +1,1 @@
177 +c1
177 +c1
178 @@ -1,0 +3,1 @@
178 @@ -1,0 +3,1 @@
179 +c3
179 +c3
180 @@ -3,1 +4,0 @@
180 @@ -3,1 +4,0 @@
181 -c5
181 -c5
182
182
183 $ hg diff -U0 --nodates --git
183 $ hg diff -U0 --nodates --git
184 diff --git a/f1 b/f1
184 diff --git a/f1 b/f1
185 --- a/f1
185 --- a/f1
186 +++ b/f1
186 +++ b/f1
187 @@ -0,0 +1,1 @@
187 @@ -0,0 +1,1 @@
188 +c1
188 +c1
189 @@ -1,0 +3,1 @@
189 @@ -1,0 +3,1 @@
190 +c3
190 +c3
191 @@ -3,1 +4,0 @@
191 @@ -3,1 +4,0 @@
192 -c5
192 -c5
193
193
194 $ hg diff -U0 --nodates -p
194 $ hg diff -U0 --nodates -p
195 diff -r 55d8ff78db23 f1
195 diff -r 55d8ff78db23 f1
196 --- a/f1
196 --- a/f1
197 +++ b/f1
197 +++ b/f1
198 @@ -0,0 +1,1 @@
198 @@ -0,0 +1,1 @@
199 +c1
199 +c1
200 @@ -1,0 +3,1 @@ c2
200 @@ -1,0 +3,1 @@ c2
201 +c3
201 +c3
202 @@ -3,1 +4,0 @@ c4
202 @@ -3,1 +4,0 @@ c4
203 -c5
203 -c5
204
204
205 $ echo a > f1
205 $ echo a > f1
206 $ hg ci -m movef2
206 $ hg ci -m movef2
207
207
208 Test diff headers terminating with TAB when necessary (issue3357)
208 Test diff headers terminating with TAB when necessary (issue3357)
209 Regular diff --nodates, file creation
209 Regular diff --nodates, file creation
210
210
211 $ hg mv f1 'f 1'
211 $ hg mv f1 'f 1'
212 $ echo b > 'f 1'
212 $ echo b > 'f 1'
213 $ hg diff --nodates 'f 1'
213 $ hg diff --nodates 'f 1'
214 diff -r 7574207d0d15 f 1
214 diff -r 7574207d0d15 f 1
215 --- /dev/null
215 --- /dev/null
216 +++ b/f 1
216 +++ b/f 1
217 @@ -0,0 +1,1 @@
217 @@ -0,0 +1,1 @@
218 +b
218 +b
219
219
220 Git diff, adding space
220 Git diff, adding space
221
221
222 $ hg diff --git
222 $ hg diff --git
223 diff --git a/f1 b/f 1
223 diff --git a/f1 b/f 1
224 rename from f1
224 rename from f1
225 rename to f 1
225 rename to f 1
226 --- a/f1
226 --- a/f1
227 +++ b/f 1
227 +++ b/f 1
228 @@ -1,1 +1,1 @@
228 @@ -1,1 +1,1 @@
229 -a
229 -a
230 +b
230 +b
231
231
232 Git diff, adding extended headers
232 Git diff, adding extended headers
233
233
234 $ hg diff --git --config experimental.extendedheader.index=7 --config experimental.extendedheader.similarity=True
234 $ hg diff --git --config experimental.extendedheader.index=7 --config experimental.extendedheader.similarity=True
235 diff --git a/f1 b/f 1
235 diff --git a/f1 b/f 1
236 similarity index 0%
236 similarity index 0%
237 rename from f1
237 rename from f1
238 rename to f 1
238 rename to f 1
239 index 7898192..6178079 100644
239 index 7898192..6178079 100644
240 --- a/f1
240 --- a/f1
241 +++ b/f 1
241 +++ b/f 1
242 @@ -1,1 +1,1 @@
242 @@ -1,1 +1,1 @@
243 -a
243 -a
244 +b
244 +b
245
245
246 $ hg diff --git --config experimental.extendedheader.index=-1
246 $ hg diff --git --config experimental.extendedheader.index=-1
247 invalid length for extendedheader.index: '-1'
247 invalid length for extendedheader.index: '-1'
248 diff --git a/f1 b/f 1
248 diff --git a/f1 b/f 1
249 rename from f1
249 rename from f1
250 rename to f 1
250 rename to f 1
251 --- a/f1
251 --- a/f1
252 +++ b/f 1
252 +++ b/f 1
253 @@ -1,1 +1,1 @@
253 @@ -1,1 +1,1 @@
254 -a
254 -a
255 +b
255 +b
256
256
257 $ hg diff --git --config experimental.extendedheader.index=whatever
257 $ hg diff --git --config experimental.extendedheader.index=whatever
258 invalid value for extendedheader.index: 'whatever'
258 invalid value for extendedheader.index: 'whatever'
259 diff --git a/f1 b/f 1
259 diff --git a/f1 b/f 1
260 rename from f1
260 rename from f1
261 rename to f 1
261 rename to f 1
262 --- a/f1
262 --- a/f1
263 +++ b/f 1
263 +++ b/f 1
264 @@ -1,1 +1,1 @@
264 @@ -1,1 +1,1 @@
265 -a
265 -a
266 +b
266 +b
267
267
268 Git diff with noprefix
268 Git diff with noprefix
269
269
270 $ hg --config diff.noprefix=True diff --git --nodates
270 $ hg --config diff.noprefix=True diff --git --nodates
271 diff --git f1 f 1
271 diff --git f1 f 1
272 rename from f1
272 rename from f1
273 rename to f 1
273 rename to f 1
274 --- f1
274 --- f1
275 +++ f 1
275 +++ f 1
276 @@ -1,1 +1,1 @@
276 @@ -1,1 +1,1 @@
277 -a
277 -a
278 +b
278 +b
279
279
280 noprefix config disabled in plain mode, but option still enabled
280 noprefix config disabled in plain mode, but option still enabled
281
281
282 $ HGPLAIN=1 hg --config diff.noprefix=True diff --git --nodates
282 $ HGPLAIN=1 hg --config diff.noprefix=True diff --git --nodates
283 diff --git a/f1 b/f 1
283 diff --git a/f1 b/f 1
284 rename from f1
284 rename from f1
285 rename to f 1
285 rename to f 1
286 --- a/f1
286 --- a/f1
287 +++ b/f 1
287 +++ b/f 1
288 @@ -1,1 +1,1 @@
288 @@ -1,1 +1,1 @@
289 -a
289 -a
290 +b
290 +b
291 $ HGPLAIN=1 hg diff --git --noprefix --nodates
291 $ HGPLAIN=1 hg diff --git --noprefix --nodates
292 diff --git f1 f 1
292 diff --git f1 f 1
293 rename from f1
293 rename from f1
294 rename to f 1
294 rename to f 1
295 --- f1
295 --- f1
296 +++ f 1
296 +++ f 1
297 @@ -1,1 +1,1 @@
297 @@ -1,1 +1,1 @@
298 -a
298 -a
299 +b
299 +b
300
300
301 Regular diff --nodates, file deletion
301 Regular diff --nodates, file deletion
302
302
303 $ hg ci -m addspace
303 $ hg ci -m addspace
304 $ hg mv 'f 1' f1
304 $ hg mv 'f 1' f1
305 $ echo a > f1
305 $ echo a > f1
306 $ hg diff --nodates 'f 1'
306 $ hg diff --nodates 'f 1'
307 diff -r ca50fe67c9c7 f 1
307 diff -r ca50fe67c9c7 f 1
308 --- a/f 1
308 --- a/f 1
309 +++ /dev/null
309 +++ /dev/null
310 @@ -1,1 +0,0 @@
310 @@ -1,1 +0,0 @@
311 -b
311 -b
312
312
313 Git diff, removing space
313 Git diff, removing space
314
314
315 $ hg diff --git
315 $ hg diff --git
316 diff --git a/f 1 b/f1
316 diff --git a/f 1 b/f1
317 rename from f 1
317 rename from f 1
318 rename to f1
318 rename to f1
319 --- a/f 1
319 --- a/f 1
320 +++ b/f1
320 +++ b/f1
321 @@ -1,1 +1,1 @@
321 @@ -1,1 +1,1 @@
322 -b
322 -b
323 +a
323 +a
324
324
325 showfunc diff
325 showfunc diff
326 $ cat > f1 << EOF
326 $ cat > f1 << EOF
327 > int main() {
327 > int main() {
328 > int a = 0;
328 > int a = 0;
329 > int b = 1;
329 > int b = 1;
330 > int c = 2;
330 > int c = 2;
331 > int d = 3;
331 > int d = 3;
332 > return a + b + c + d;
332 > return a + b + c + d;
333 > }
333 > }
334 > EOF
334 > EOF
335 $ hg commit -m addfunction
335 $ hg commit -m addfunction
336 $ cat > f1 << EOF
336 $ cat > f1 << EOF
337 > int main() {
337 > int main() {
338 > int a = 0;
338 > int a = 0;
339 > int b = 1;
339 > int b = 1;
340 > int c = 2;
340 > int c = 2;
341 > int e = 3;
341 > int e = 3;
342 > return a + b + c + e;
342 > return a + b + c + e;
343 > }
343 > }
344 > EOF
344 > EOF
345 $ hg diff --git
345 $ hg diff --git
346 diff --git a/f1 b/f1
346 diff --git a/f1 b/f1
347 --- a/f1
347 --- a/f1
348 +++ b/f1
348 +++ b/f1
349 @@ -2,6 +2,6 @@
349 @@ -2,6 +2,6 @@
350 int a = 0;
350 int a = 0;
351 int b = 1;
351 int b = 1;
352 int c = 2;
352 int c = 2;
353 - int d = 3;
353 - int d = 3;
354 - return a + b + c + d;
354 - return a + b + c + d;
355 + int e = 3;
355 + int e = 3;
356 + return a + b + c + e;
356 + return a + b + c + e;
357 }
357 }
358 $ hg diff --config diff.showfunc=True --git
358 $ hg diff --config diff.showfunc=True --git
359 diff --git a/f1 b/f1
359 diff --git a/f1 b/f1
360 --- a/f1
360 --- a/f1
361 +++ b/f1
361 +++ b/f1
362 @@ -2,6 +2,6 @@ int main() {
362 @@ -2,6 +2,6 @@ int main() {
363 int a = 0;
363 int a = 0;
364 int b = 1;
364 int b = 1;
365 int c = 2;
365 int c = 2;
366 - int d = 3;
366 - int d = 3;
367 - return a + b + c + d;
367 - return a + b + c + d;
368 + int e = 3;
368 + int e = 3;
369 + return a + b + c + e;
369 + return a + b + c + e;
370 }
370 }
371
371
372 If [diff] git is set to true, but the user says --no-git, we should
372 If [diff] git is set to true, but the user says --no-git, we should
373 *not* get git diffs
373 *not* get git diffs
374 $ hg diff --nodates --config diff.git=1 --no-git
374 $ hg diff --nodates --config diff.git=1 --no-git
375 diff -r f2c7c817fa55 f1
375 diff -r f2c7c817fa55 f1
376 --- a/f1
376 --- a/f1
377 +++ b/f1
377 +++ b/f1
378 @@ -2,6 +2,6 @@
378 @@ -2,6 +2,6 @@
379 int a = 0;
379 int a = 0;
380 int b = 1;
380 int b = 1;
381 int c = 2;
381 int c = 2;
382 - int d = 3;
382 - int d = 3;
383 - return a + b + c + d;
383 - return a + b + c + d;
384 + int e = 3;
384 + int e = 3;
385 + return a + b + c + e;
385 + return a + b + c + e;
386 }
386 }
387
387
388 $ cd ..
388 $ cd ..
389
389
390 Long function names should be abbreviated, but multi-byte character shouldn't
390 Long function names should be abbreviated, but multi-byte character shouldn't
391 be broken up
391 be broken up
392
392
393 $ hg init longfunc
393 $ hg init longfunc
394 $ cd longfunc
394 $ cd longfunc
395
395
396 >>> with open('a', 'wb') as f:
396 >>> with open('a', 'wb') as f:
397 ... f.write(b'a' * 39 + b'bb' + b'\n')
397 ... f.write(b'a' * 39 + b'bb' + b'\n') and None
398 ... f.write(b' .\n' * 3)
398 ... f.write(b' .\n' * 3) and None
399 ... f.write(b' 0 b\n')
399 ... f.write(b' 0 b\n') and None
400 ... f.write(b' .\n' * 3)
400 ... f.write(b' .\n' * 3) and None
401 ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n')
401 ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') and None
402 ... f.write(b' .\n' * 3)
402 ... f.write(b' .\n' * 3) and None
403 ... f.write(b' 0 a with grave (single code point)\n')
403 ... f.write(b' 0 a with grave (single code point)\n') and None
404 ... f.write(b' .\n' * 3)
404 ... f.write(b' .\n' * 3) and None
405 ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n')
405 ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') and None
406 ... f.write(b' .\n' * 3)
406 ... f.write(b' .\n' * 3) and None
407 ... f.write(b' 0 a with grave (composition)\n')
407 ... f.write(b' 0 a with grave (composition)\n') and None
408 ... f.write(b' .\n' * 3)
408 ... f.write(b' .\n' * 3) and None
409 $ hg ci -qAm0
409 $ hg ci -qAm0
410
410
411 >>> with open('a', 'wb') as f:
411 >>> with open('a', 'wb') as f:
412 ... f.write(b'a' * 39 + b'bb' + b'\n')
412 ... f.write(b'a' * 39 + b'bb' + b'\n') and None
413 ... f.write(b' .\n' * 3)
413 ... f.write(b' .\n' * 3) and None
414 ... f.write(b' 1 b\n')
414 ... f.write(b' 1 b\n') and None
415 ... f.write(b' .\n' * 3)
415 ... f.write(b' .\n' * 3) and None
416 ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n')
416 ... f.write(b'a' * 39 + b'\xc3\xa0' + b'\n') and None
417 ... f.write(b' .\n' * 3)
417 ... f.write(b' .\n' * 3) and None
418 ... f.write(b' 1 a with grave (single code point)\n')
418 ... f.write(b' 1 a with grave (single code point)\n') and None
419 ... f.write(b' .\n' * 3)
419 ... f.write(b' .\n' * 3) and None
420 ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n')
420 ... f.write(b'a' * 39 + b'a\xcc\x80' + b'\n') and None
421 ... f.write(b' .\n' * 3)
421 ... f.write(b' .\n' * 3) and None
422 ... f.write(b' 1 a with grave (composition)\n')
422 ... f.write(b' 1 a with grave (composition)\n') and None
423 ... f.write(b' .\n' * 3)
423 ... f.write(b' .\n' * 3) and None
424 $ hg ci -m1
424 $ hg ci -m1
425
425
426 $ hg diff -c1 --nodates --show-function
426 $ hg diff -c1 --nodates --show-function
427 diff -r 3e92dd6fa812 -r a256341606cb a
427 diff -r 3e92dd6fa812 -r a256341606cb a
428 --- a/a
428 --- a/a
429 +++ b/a
429 +++ b/a
430 @@ -2,7 +2,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
430 @@ -2,7 +2,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab
431 .
431 .
432 .
432 .
433 .
433 .
434 - 0 b
434 - 0 b
435 + 1 b
435 + 1 b
436 .
436 .
437 .
437 .
438 .
438 .
439 @@ -10,7 +10,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xc3\xa0 (esc)
439 @@ -10,7 +10,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xc3\xa0 (esc)
440 .
440 .
441 .
441 .
442 .
442 .
443 - 0 a with grave (single code point)
443 - 0 a with grave (single code point)
444 + 1 a with grave (single code point)
444 + 1 a with grave (single code point)
445 .
445 .
446 .
446 .
447 .
447 .
448 @@ -18,7 +18,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xcc\x80 (esc)
448 @@ -18,7 +18,7 @@ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\xcc\x80 (esc)
449 .
449 .
450 .
450 .
451 .
451 .
452 - 0 a with grave (composition)
452 - 0 a with grave (composition)
453 + 1 a with grave (composition)
453 + 1 a with grave (composition)
454 .
454 .
455 .
455 .
456 .
456 .
457
457
458 $ cd ..
458 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now