##// END OF EJS Templates
tests: add diff color trailing whitespace test
Sune Foldager -
r38682:b07b691d default
parent child Browse files
Show More
@@ -1,393 +1,414 b''
1 1 Setup
2 2
3 3 $ cat <<EOF >> $HGRCPATH
4 4 > [ui]
5 5 > color = yes
6 6 > formatted = always
7 7 > paginate = never
8 8 > [color]
9 9 > mode = ansi
10 10 > EOF
11 11 $ hg init repo
12 12 $ cd repo
13 13 $ cat > a <<EOF
14 14 > c
15 15 > c
16 16 > a
17 17 > a
18 18 > b
19 19 > a
20 20 > a
21 21 > c
22 22 > c
23 23 > EOF
24 24 $ hg ci -Am adda
25 25 adding a
26 26 $ cat > a <<EOF
27 27 > c
28 28 > c
29 29 > a
30 30 > a
31 31 > dd
32 32 > a
33 33 > a
34 34 > c
35 35 > c
36 36 > EOF
37 37
38 38 default context
39 39
40 40 $ hg diff --nodates
41 41 \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc)
42 42 \x1b[0;31;1m--- a/a\x1b[0m (esc)
43 43 \x1b[0;32;1m+++ b/a\x1b[0m (esc)
44 44 \x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc)
45 45 c
46 46 a
47 47 a
48 48 \x1b[0;31m-b\x1b[0m (esc)
49 49 \x1b[0;32m+dd\x1b[0m (esc)
50 50 a
51 51 a
52 52 c
53 53
54 trailing whitespace
55
56 $ cp a a.orig
57 $ sed 's/^dd$/dd \r/' a >a.new
58 $ mv a.new a
59 $ hg diff --nodates
60 \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc)
61 \x1b[0;31;1m--- a/a\x1b[0m (esc)
62 \x1b[0;32;1m+++ b/a\x1b[0m (esc)
63 \x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc)
64 c
65 a
66 a
67 \x1b[0;31m-b\x1b[0m (esc)
68 \x1b[0;32m+dd\x1b[0m\x1b[0;1;41m \x1b[0m\r (esc)
69 a
70 a
71 c
72
73 $ mv a.orig a
74
54 75 (check that 'ui.color=yes' match '--color=auto')
55 76
56 77 $ hg diff --nodates --config ui.formatted=no
57 78 diff -r cf9f4ba66af2 a
58 79 --- a/a
59 80 +++ b/a
60 81 @@ -2,7 +2,7 @@
61 82 c
62 83 a
63 84 a
64 85 -b
65 86 +dd
66 87 a
67 88 a
68 89 c
69 90
70 91 (check that 'ui.color=no' disable color)
71 92
72 93 $ hg diff --nodates --config ui.formatted=yes --config ui.color=no
73 94 diff -r cf9f4ba66af2 a
74 95 --- a/a
75 96 +++ b/a
76 97 @@ -2,7 +2,7 @@
77 98 c
78 99 a
79 100 a
80 101 -b
81 102 +dd
82 103 a
83 104 a
84 105 c
85 106
86 107 (check that 'ui.color=always' force color)
87 108
88 109 $ hg diff --nodates --config ui.formatted=no --config ui.color=always
89 110 \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc)
90 111 \x1b[0;31;1m--- a/a\x1b[0m (esc)
91 112 \x1b[0;32;1m+++ b/a\x1b[0m (esc)
92 113 \x1b[0;35m@@ -2,7 +2,7 @@\x1b[0m (esc)
93 114 c
94 115 a
95 116 a
96 117 \x1b[0;31m-b\x1b[0m (esc)
97 118 \x1b[0;32m+dd\x1b[0m (esc)
98 119 a
99 120 a
100 121 c
101 122
102 123 --unified=2
103 124
104 125 $ hg diff --nodates -U 2
105 126 \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc)
106 127 \x1b[0;31;1m--- a/a\x1b[0m (esc)
107 128 \x1b[0;32;1m+++ b/a\x1b[0m (esc)
108 129 \x1b[0;35m@@ -3,5 +3,5 @@\x1b[0m (esc)
109 130 a
110 131 a
111 132 \x1b[0;31m-b\x1b[0m (esc)
112 133 \x1b[0;32m+dd\x1b[0m (esc)
113 134 a
114 135 a
115 136
116 137 diffstat
117 138
118 139 $ hg diff --stat
119 140 a | 2 \x1b[0;32m+\x1b[0m\x1b[0;31m-\x1b[0m (esc)
120 141 1 files changed, 1 insertions(+), 1 deletions(-)
121 142 $ cat <<EOF >> $HGRCPATH
122 143 > [extensions]
123 144 > record =
124 145 > [ui]
125 146 > interactive = true
126 147 > [diff]
127 148 > git = True
128 149 > EOF
129 150
130 151 #if execbit
131 152
132 153 record
133 154
134 155 $ chmod +x a
135 156 $ hg record -m moda a <<EOF
136 157 > y
137 158 > y
138 159 > EOF
139 160 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
140 161 \x1b[0;36;1mold mode 100644\x1b[0m (esc)
141 162 \x1b[0;36;1mnew mode 100755\x1b[0m (esc)
142 163 1 hunks, 1 lines changed
143 164 \x1b[0;33mexamine changes to 'a'? [Ynesfdaq?]\x1b[0m y (esc)
144 165
145 166 \x1b[0;35m@@ -2,7 +2,7 @@ c\x1b[0m (esc)
146 167 c
147 168 a
148 169 a
149 170 \x1b[0;31m-b\x1b[0m (esc)
150 171 \x1b[0;32m+dd\x1b[0m (esc)
151 172 a
152 173 a
153 174 c
154 175 \x1b[0;33mrecord this change to 'a'? [Ynesfdaq?]\x1b[0m y (esc)
155 176
156 177
157 178 $ echo "[extensions]" >> $HGRCPATH
158 179 $ echo "mq=" >> $HGRCPATH
159 180 $ hg rollback
160 181 repository tip rolled back to revision 0 (undo commit)
161 182 working directory now based on revision 0
162 183
163 184 qrecord
164 185
165 186 $ hg qrecord -m moda patch <<EOF
166 187 > y
167 188 > y
168 189 > EOF
169 190 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
170 191 \x1b[0;36;1mold mode 100644\x1b[0m (esc)
171 192 \x1b[0;36;1mnew mode 100755\x1b[0m (esc)
172 193 1 hunks, 1 lines changed
173 194 \x1b[0;33mexamine changes to 'a'? [Ynesfdaq?]\x1b[0m y (esc)
174 195
175 196 \x1b[0;35m@@ -2,7 +2,7 @@ c\x1b[0m (esc)
176 197 c
177 198 a
178 199 a
179 200 \x1b[0;31m-b\x1b[0m (esc)
180 201 \x1b[0;32m+dd\x1b[0m (esc)
181 202 a
182 203 a
183 204 c
184 205 \x1b[0;33mrecord this change to 'a'? [Ynesfdaq?]\x1b[0m y (esc)
185 206
186 207
187 208 $ hg qpop -a
188 209 popping patch
189 210 patch queue now empty
190 211
191 212 #endif
192 213
193 214 issue3712: test colorization of subrepo diff
194 215
195 216 $ hg init sub
196 217 $ echo b > sub/b
197 218 $ hg -R sub commit -Am 'create sub'
198 219 adding b
199 220 $ echo 'sub = sub' > .hgsub
200 221 $ hg add .hgsub
201 222 $ hg commit -m 'add subrepo sub'
202 223 $ echo aa >> a
203 224 $ echo bb >> sub/b
204 225
205 226 $ hg diff -S
206 227 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
207 228 \x1b[0;31;1m--- a/a\x1b[0m (esc)
208 229 \x1b[0;32;1m+++ b/a\x1b[0m (esc)
209 230 \x1b[0;35m@@ -7,3 +7,4 @@\x1b[0m (esc)
210 231 a
211 232 c
212 233 c
213 234 \x1b[0;32m+aa\x1b[0m (esc)
214 235 \x1b[0;1mdiff --git a/sub/b b/sub/b\x1b[0m (esc)
215 236 \x1b[0;31;1m--- a/sub/b\x1b[0m (esc)
216 237 \x1b[0;32;1m+++ b/sub/b\x1b[0m (esc)
217 238 \x1b[0;35m@@ -1,1 +1,2 @@\x1b[0m (esc)
218 239 b
219 240 \x1b[0;32m+bb\x1b[0m (esc)
220 241
221 242 test tabs
222 243
223 244 $ cat >> a <<EOF
224 245 > one tab
225 246 > two tabs
226 247 > end tab
227 248 > mid tab
228 249 > all tabs
229 250 > EOF
230 251 $ hg diff --nodates
231 252 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
232 253 \x1b[0;31;1m--- a/a\x1b[0m (esc)
233 254 \x1b[0;32;1m+++ b/a\x1b[0m (esc)
234 255 \x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc)
235 256 a
236 257 c
237 258 c
238 259 \x1b[0;32m+aa\x1b[0m (esc)
239 260 \x1b[0;32m+\x1b[0m \x1b[0;32mone tab\x1b[0m (esc)
240 261 \x1b[0;32m+\x1b[0m \x1b[0;32mtwo tabs\x1b[0m (esc)
241 262 \x1b[0;32m+end tab\x1b[0m\x1b[0;1;41m \x1b[0m (esc)
242 263 \x1b[0;32m+mid\x1b[0m \x1b[0;32mtab\x1b[0m (esc)
243 264 \x1b[0;32m+\x1b[0m \x1b[0;32mall\x1b[0m \x1b[0;32mtabs\x1b[0m\x1b[0;1;41m \x1b[0m (esc)
244 265 $ echo "[color]" >> $HGRCPATH
245 266 $ echo "diff.tab = bold magenta" >> $HGRCPATH
246 267 $ hg diff --nodates
247 268 \x1b[0;1mdiff --git a/a b/a\x1b[0m (esc)
248 269 \x1b[0;31;1m--- a/a\x1b[0m (esc)
249 270 \x1b[0;32;1m+++ b/a\x1b[0m (esc)
250 271 \x1b[0;35m@@ -7,3 +7,9 @@\x1b[0m (esc)
251 272 a
252 273 c
253 274 c
254 275 \x1b[0;32m+aa\x1b[0m (esc)
255 276 \x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mone tab\x1b[0m (esc)
256 277 \x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtwo tabs\x1b[0m (esc)
257 278 \x1b[0;32m+end tab\x1b[0m\x1b[0;1;41m \x1b[0m (esc)
258 279 \x1b[0;32m+mid\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtab\x1b[0m (esc)
259 280 \x1b[0;32m+\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mall\x1b[0m\x1b[0;1;35m \x1b[0m\x1b[0;32mtabs\x1b[0m\x1b[0;1;41m \x1b[0m (esc)
260 281
261 282 $ cd ..
262 283
263 284 test inline color diff
264 285
265 286 $ hg init inline
266 287 $ cd inline
267 288 $ cat > file1 << EOF
268 289 > this is the first line
269 290 > this is the second line
270 291 > third line starts with space
271 292 > + starts with a plus sign
272 293 > this one with one tab
273 294 > now with full two tabs
274 295 > now tabs everywhere, much fun
275 296 >
276 297 > this line won't change
277 298 >
278 299 > two lines are going to
279 300 > be changed into three!
280 301 >
281 302 > three of those lines will
282 303 > collapse onto one
283 304 > (to see if it works)
284 305 > EOF
285 306 $ hg add file1
286 307 $ hg ci -m 'commit'
287 308
288 309 $ cat > file1 << EOF
289 310 > that is the first paragraph
290 311 > this is the second line
291 312 > third line starts with space
292 313 > - starts with a minus sign
293 314 > this one with two tab
294 315 > now with full three tabs
295 316 > now there are tabs everywhere, much fun
296 317 >
297 318 > this line won't change
298 319 >
299 320 > two lines are going to
300 321 > (entirely magically,
301 322 > assuming this works)
302 323 > be changed into four!
303 324 >
304 325 > three of those lines have
305 326 > collapsed onto one
306 327 > EOF
307 328 $ hg diff --config diff.word-diff=False --color=debug
308 329 [diff.diffline|diff --git a/file1 b/file1]
309 330 [diff.file_a|--- a/file1]
310 331 [diff.file_b|+++ b/file1]
311 332 [diff.hunk|@@ -1,16 +1,17 @@]
312 333 [diff.deleted|-this is the first line]
313 334 [diff.deleted|-this is the second line]
314 335 [diff.deleted|- third line starts with space]
315 336 [diff.deleted|-+ starts with a plus sign]
316 337 [diff.deleted|-][diff.tab| ][diff.deleted|this one with one tab]
317 338 [diff.deleted|-][diff.tab| ][diff.deleted|now with full two tabs]
318 339 [diff.deleted|-][diff.tab| ][diff.deleted|now tabs][diff.tab| ][diff.deleted|everywhere, much fun]
319 340 [diff.inserted|+that is the first paragraph]
320 341 [diff.inserted|+ this is the second line]
321 342 [diff.inserted|+third line starts with space]
322 343 [diff.inserted|+- starts with a minus sign]
323 344 [diff.inserted|+][diff.tab| ][diff.inserted|this one with two tab]
324 345 [diff.inserted|+][diff.tab| ][diff.inserted|now with full three tabs]
325 346 [diff.inserted|+][diff.tab| ][diff.inserted|now there are tabs][diff.tab| ][diff.inserted|everywhere, much fun]
326 347
327 348 this line won't change
328 349
329 350 two lines are going to
330 351 [diff.deleted|-be changed into three!]
331 352 [diff.inserted|+(entirely magically,]
332 353 [diff.inserted|+ assuming this works)]
333 354 [diff.inserted|+be changed into four!]
334 355
335 356 [diff.deleted|-three of those lines will]
336 357 [diff.deleted|-collapse onto one]
337 358 [diff.deleted|-(to see if it works)]
338 359 [diff.inserted|+three of those lines have]
339 360 [diff.inserted|+collapsed onto one]
340 361 $ hg diff --config diff.word-diff=True --color=debug
341 362 [diff.diffline|diff --git a/file1 b/file1]
342 363 [diff.file_a|--- a/file1]
343 364 [diff.file_b|+++ b/file1]
344 365 [diff.hunk|@@ -1,16 +1,17 @@]
345 366 [diff.deleted|-][diff.deleted.changed|this][diff.deleted.unchanged| is the first ][diff.deleted.changed|line]
346 367 [diff.deleted|-][diff.deleted.unchanged|this is the second line]
347 368 [diff.deleted|-][diff.deleted.changed| ][diff.deleted.unchanged|third line starts with space]
348 369 [diff.deleted|-][diff.deleted.changed|+][diff.deleted.unchanged| starts with a ][diff.deleted.changed|plus][diff.deleted.unchanged| sign]
349 370 [diff.deleted|-][diff.tab| ][diff.deleted.unchanged|this one with ][diff.deleted.changed|one][diff.deleted.unchanged| tab]
350 371 [diff.deleted|-][diff.tab| ][diff.deleted.unchanged|now with full ][diff.deleted.changed|two][diff.deleted.unchanged| tabs]
351 372 [diff.deleted|-][diff.tab| ][diff.deleted.unchanged|now ][diff.deleted.unchanged|tabs][diff.tab| ][diff.deleted.unchanged|everywhere, much fun]
352 373 [diff.inserted|+][diff.inserted.changed|that][diff.inserted.unchanged| is the first ][diff.inserted.changed|paragraph]
353 374 [diff.inserted|+][diff.inserted.changed| ][diff.inserted.unchanged|this is the second line]
354 375 [diff.inserted|+][diff.inserted.unchanged|third line starts with space]
355 376 [diff.inserted|+][diff.inserted.changed|-][diff.inserted.unchanged| starts with a ][diff.inserted.changed|minus][diff.inserted.unchanged| sign]
356 377 [diff.inserted|+][diff.tab| ][diff.inserted.unchanged|this one with ][diff.inserted.changed|two][diff.inserted.unchanged| tab]
357 378 [diff.inserted|+][diff.tab| ][diff.inserted.unchanged|now with full ][diff.inserted.changed|three][diff.inserted.unchanged| tabs]
358 379 [diff.inserted|+][diff.tab| ][diff.inserted.unchanged|now ][diff.inserted.changed|there are ][diff.inserted.unchanged|tabs][diff.tab| ][diff.inserted.unchanged|everywhere, much fun]
359 380
360 381 this line won't change
361 382
362 383 two lines are going to
363 384 [diff.deleted|-][diff.deleted.unchanged|be changed into ][diff.deleted.changed|three][diff.deleted.unchanged|!]
364 385 [diff.inserted|+][diff.inserted.changed|(entirely magically,]
365 386 [diff.inserted|+][diff.inserted.changed| assuming this works)]
366 387 [diff.inserted|+][diff.inserted.unchanged|be changed into ][diff.inserted.changed|four][diff.inserted.unchanged|!]
367 388
368 389 [diff.deleted|-][diff.deleted.unchanged|three of those lines ][diff.deleted.changed|will]
369 390 [diff.deleted|-][diff.deleted.changed|collapse][diff.deleted.unchanged| onto one]
370 391 [diff.deleted|-][diff.deleted.changed|(to see if it works)]
371 392 [diff.inserted|+][diff.inserted.unchanged|three of those lines ][diff.inserted.changed|have]
372 393 [diff.inserted|+][diff.inserted.changed|collapsed][diff.inserted.unchanged| onto one]
373 394
374 395 multibyte character shouldn't be broken up in word diff:
375 396
376 397 $ $PYTHON <<'EOF'
377 398 > with open("utf8", "wb") as f:
378 399 > f.write(b"blah \xe3\x82\xa2 blah\n")
379 400 > EOF
380 401 $ hg ci -Am 'add utf8 char' utf8
381 402 $ $PYTHON <<'EOF'
382 403 > with open("utf8", "wb") as f:
383 404 > f.write(b"blah \xe3\x82\xa4 blah\n")
384 405 > EOF
385 406 $ hg ci -m 'slightly change utf8 char' utf8
386 407
387 408 $ hg diff --config diff.word-diff=True --color=debug -c.
388 409 [diff.diffline|diff --git a/utf8 b/utf8]
389 410 [diff.file_a|--- a/utf8]
390 411 [diff.file_b|+++ b/utf8]
391 412 [diff.hunk|@@ -1,1 +1,1 @@]
392 413 [diff.deleted|-][diff.deleted.unchanged|blah ][diff.deleted.changed|\xe3\x82\xa2][diff.deleted.unchanged| blah] (esc)
393 414 [diff.inserted|+][diff.inserted.unchanged|blah ][diff.inserted.changed|\xe3\x82\xa4][diff.inserted.unchanged| blah] (esc)
General Comments 0
You need to be logged in to leave comments. Login now