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