##// END OF EJS Templates
tests: remove undefined (empty) $opt from test-extdiff.t...
Martin von Zweigbergk -
r46746:60677eca default
parent child Browse files
Show More
@@ -1,545 +1,545 b''
1 1 $ echo "[extensions]" >> $HGRCPATH
2 2 $ echo "extdiff=" >> $HGRCPATH
3 3
4 4 $ hg init a
5 5 $ cd a
6 6 $ echo a > a
7 7 $ echo b > b
8 8 $ hg add
9 9 adding a
10 10 adding b
11 11
12 12 Should diff cloned directories:
13 13
14 $ hg extdiff -o -r $opt
14 $ hg extdiff -o -r
15 15 Only in a: a
16 16 Only in a: b
17 17 [1]
18 18
19 19 $ cat <<EOF >> $HGRCPATH
20 20 > [extdiff]
21 21 > cmd.falabala = echo
22 22 > opts.falabala = diffing
23 23 > cmd.edspace = echo
24 24 > opts.edspace = "name <user@example.com>"
25 25 > alabalaf =
26 26 > [merge-tools]
27 27 > alabalaf.executable = echo
28 28 > alabalaf.diffargs = diffing
29 29 > EOF
30 30
31 31 $ hg falabala
32 32 diffing a.000000000000 a
33 33 [1]
34 34
35 35 $ hg help falabala
36 36 hg falabala [OPTION]... [FILE]...
37 37
38 38 use external program to diff repository (or selected files)
39 39
40 40 Show differences between revisions for the specified files, using the
41 41 following program:
42 42
43 43 'echo'
44 44
45 45 When two revision arguments are given, then changes are shown between
46 46 those revisions. If only one revision is specified then that revision is
47 47 compared to the working directory, and, when no revisions are specified,
48 48 the working directory files are compared to its parent.
49 49
50 50 options ([+] can be repeated):
51 51
52 52 -o --option OPT [+] pass option to comparison program
53 53 -r --rev REV [+] revision
54 54 -c --change REV change made by revision
55 55 --per-file compare each file instead of revision snapshots
56 56 --confirm prompt user before each external program invocation
57 57 --patch compare patches for two revisions
58 58 -I --include PATTERN [+] include names matching the given patterns
59 59 -X --exclude PATTERN [+] exclude names matching the given patterns
60 60 -S --subrepos recurse into subrepositories
61 61
62 62 (some details hidden, use --verbose to show complete help)
63 63
64 64 $ hg ci -d '0 0' -mtest1
65 65
66 66 $ echo b >> a
67 67 $ hg ci -d '1 0' -mtest2
68 68
69 69 Should diff cloned files directly:
70 70
71 71 $ hg falabala -r 0:1
72 72 diffing "*\\extdiff.*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
73 73 diffing */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
74 74 [1]
75 75
76 76 Specifying an empty revision should abort.
77 77
78 78 $ hg extdiff -p diff --patch --rev 'ancestor()' --rev 1
79 79 abort: empty revision on one side of range
80 80 [255]
81 81
82 82 Test diff during merge:
83 83
84 84 $ hg update -C 0
85 85 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
86 86 $ echo c >> c
87 87 $ hg add c
88 88 $ hg ci -m "new branch" -d '1 0'
89 89 created new head
90 90 $ hg merge 1
91 91 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
92 92 (branch merge, don't forget to commit)
93 93
94 94 Should diff cloned file against wc file:
95 95
96 96 $ hg falabala
97 97 diffing "*\\extdiff.*\\a.2a13a4d2da36\\a" "*\\a\\a" (glob) (windows !)
98 98 diffing */extdiff.*/a.2a13a4d2da36/a */a/a (glob) (no-windows !)
99 99 [1]
100 100
101 101
102 102 Test --change option:
103 103
104 104 $ hg ci -d '2 0' -mtest3
105 105
106 106 $ hg falabala -c 1
107 107 diffing "*\\extdiff.*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
108 108 diffing */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
109 109 [1]
110 110
111 111 Check diff are made from the first parent:
112 112
113 113 $ hg falabala -c 3 || echo "diff-like tools yield a non-zero exit code"
114 114 diffing "*\\extdiff.*\\a.2a13a4d2da36\\a" "a.46c0e4daeb72\\a" (glob) (windows !)
115 115 diffing */extdiff.*/a.2a13a4d2da36/a a.46c0e4daeb72/a (glob) (no-windows !)
116 116 diff-like tools yield a non-zero exit code
117 117
118 118 issue3153: ensure using extdiff with removed subrepos doesn't crash:
119 119
120 120 $ hg init suba
121 121 $ cd suba
122 122 $ echo suba > suba
123 123 $ hg add
124 124 adding suba
125 125 $ hg ci -m "adding suba file"
126 126 $ cd ..
127 127 $ echo suba=suba > .hgsub
128 128 $ hg add
129 129 adding .hgsub
130 130 $ hg ci -Sm "adding subrepo"
131 131 $ echo > .hgsub
132 132 $ hg ci -m "removing subrepo"
133 133 $ hg falabala -r 4 -r 5 -S
134 134 diffing a.398e36faf9c6 a.5ab95fb166c4
135 135 [1]
136 136
137 137 Test --per-file option:
138 138
139 139 $ hg up -q -C 3
140 140 $ echo a2 > a
141 141 $ echo b2 > b
142 142 $ hg ci -d '3 0' -mtestmode1
143 143 created new head
144 144 $ hg falabala -c 6 --per-file
145 145 diffing "*\\extdiff.*\\a.46c0e4daeb72\\a" "a.81906f2b98ac\\a" (glob) (windows !)
146 146 diffing */extdiff.*/a.46c0e4daeb72/a a.81906f2b98ac/a (glob) (no-windows !)
147 147 diffing "*\\extdiff.*\\a.46c0e4daeb72\\b" "a.81906f2b98ac\\b" (glob) (windows !)
148 148 diffing */extdiff.*/a.46c0e4daeb72/b a.81906f2b98ac/b (glob) (no-windows !)
149 149 [1]
150 150
151 151 Test --per-file option for gui tool:
152 152
153 153 $ hg --config extdiff.gui.alabalaf=True alabalaf -c 6 --per-file --debug
154 154 diffing */extdiff.*/a.46c0e4daeb72/* a.81906f2b98ac/* (glob)
155 155 diffing */extdiff.*/a.46c0e4daeb72/* a.81906f2b98ac/* (glob)
156 156 making snapshot of 2 files from rev 46c0e4daeb72
157 157 a
158 158 b
159 159 making snapshot of 2 files from rev 81906f2b98ac
160 160 a
161 161 b
162 162 running '* diffing * *' in * (backgrounded) (glob)
163 163 running '* diffing * *' in * (backgrounded) (glob)
164 164 cleaning up temp directory
165 165 [1]
166 166
167 167 Test --per-file option for gui tool again:
168 168
169 169 $ hg --config merge-tools.alabalaf.gui=True alabalaf -c 6 --per-file --debug
170 170 diffing */extdiff.*/a.46c0e4daeb72/* a.81906f2b98ac/* (glob)
171 171 diffing */extdiff.*/a.46c0e4daeb72/* a.81906f2b98ac/* (glob)
172 172 making snapshot of 2 files from rev 46c0e4daeb72
173 173 a
174 174 b
175 175 making snapshot of 2 files from rev 81906f2b98ac
176 176 a
177 177 b
178 178 running '* diffing * *' in * (backgrounded) (glob)
179 179 running '* diffing * *' in * (backgrounded) (glob)
180 180 cleaning up temp directory
181 181 [1]
182 182
183 183 Test --per-file and --confirm options:
184 184
185 185 $ hg --config ui.interactive=True falabala -c 6 --per-file --confirm <<EOF
186 186 > n
187 187 > y
188 188 > EOF
189 189 diff a (1 of 2) [Yns?] n
190 190 diff b (2 of 2) [Yns?] y
191 191 diffing "*\\extdiff.*\\a.46c0e4daeb72\\b" "a.81906f2b98ac\\b" (glob) (windows !)
192 192 diffing */extdiff.*/a.46c0e4daeb72/b a.81906f2b98ac/b (glob) (no-windows !)
193 193 [1]
194 194
195 195 Test --per-file and --confirm options with skipping:
196 196
197 197 $ hg --config ui.interactive=True falabala -c 6 --per-file --confirm <<EOF
198 198 > s
199 199 > EOF
200 200 diff a (1 of 2) [Yns?] s
201 201 [1]
202 202
203 203 issue4463: usage of command line configuration without additional quoting
204 204
205 205 $ cat <<EOF >> $HGRCPATH
206 206 > [extdiff]
207 207 > cmd.4463a = echo
208 208 > opts.4463a = a-naked 'single quoted' "double quoted"
209 209 > 4463b = echo b-naked 'single quoted' "double quoted"
210 210 > echo =
211 211 > EOF
212 212 $ hg update -q -C 0
213 213 $ echo a >> a
214 214
215 215 $ hg --debug 4463a | grep '^running'
216 216 running 'echo a-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
217 217 running 'echo a-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
218 218 $ hg --debug 4463b | grep '^running'
219 219 running 'echo b-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
220 220 running 'echo b-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
221 221 $ hg --debug echo | grep '^running'
222 222 running '*echo* "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
223 223 running '*echo */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
224 224
225 225 (getting options from other than extdiff section)
226 226
227 227 $ cat <<EOF >> $HGRCPATH
228 228 > [extdiff]
229 229 > # using diff-tools diffargs
230 230 > 4463b2 = echo
231 231 > # using merge-tools diffargs
232 232 > 4463b3 = echo
233 233 > # no diffargs
234 234 > 4463b4 = echo
235 235 > [diff-tools]
236 236 > 4463b2.diffargs = b2-naked 'single quoted' "double quoted"
237 237 > [merge-tools]
238 238 > 4463b3.diffargs = b3-naked 'single quoted' "double quoted"
239 239 > EOF
240 240
241 241 $ hg --debug 4463b2 | grep '^running'
242 242 running 'echo b2-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
243 243 running 'echo b2-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
244 244 $ hg --debug 4463b3 | grep '^running'
245 245 running 'echo b3-naked \'single quoted\' "double quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
246 246 running 'echo b3-naked \'single quoted\' "double quoted" */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
247 247 $ hg --debug 4463b4 | grep '^running'
248 248 running 'echo "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
249 249 running 'echo */a $TESTTMP/a/a' in */extdiff.* (glob) (no-windows !)
250 250 $ hg --debug 4463b4 --option b4-naked --option 'being quoted' | grep '^running'
251 251 running 'echo b4-naked "being quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
252 252 running "echo b4-naked 'being quoted' */a $TESTTMP/a/a" in */extdiff.* (glob) (no-windows !)
253 253 $ hg --debug extdiff -p echo --option echo-naked --option 'being quoted' | grep '^running'
254 254 running 'echo echo-naked "being quoted" "*\\a" "*\\a"' in */extdiff.* (glob) (windows !)
255 255 running "echo echo-naked 'being quoted' */a $TESTTMP/a/a" in */extdiff.* (glob) (no-windows !)
256 256
257 257 $ touch 'sp ace'
258 258 $ hg add 'sp ace'
259 259 $ hg ci -m 'sp ace'
260 260 created new head
261 261 $ echo > 'sp ace'
262 262
263 263 Test pre-72a89cf86fcd backward compatibility with half-baked manual quoting
264 264
265 265 $ cat <<EOF >> $HGRCPATH
266 266 > [extdiff]
267 267 > odd =
268 268 > [merge-tools]
269 269 > odd.diffargs = --foo='\$clabel' '\$clabel' "--bar=\$clabel" "\$clabel"
270 270 > odd.executable = echo
271 271 > EOF
272 272
273 273 $ hg --debug odd | grep '^running'
274 274 running '"*\\echo.exe" --foo="sp ace" "sp ace" --bar="sp ace" "sp ace"' in * (glob) (windows !)
275 275 running "*/echo --foo='sp ace' 'sp ace' --bar='sp ace' 'sp ace'" in * (glob) (no-windows !)
276 276
277 277 Empty argument must be quoted
278 278
279 279 $ cat <<EOF >> $HGRCPATH
280 280 > [extdiff]
281 281 > kdiff3 = echo
282 282 > [merge-tools]
283 283 > kdiff3.diffargs=--L1 \$plabel1 --L2 \$clabel \$parent \$child
284 284 > EOF
285 285
286 286 $ hg --debug kdiff3 -r0 | grep '^running'
287 287 running 'echo --L1 "@0" --L2 "" a.8a5febb7f867 a' in * (glob) (windows !)
288 288 running "echo --L1 '@0' --L2 '' a.8a5febb7f867 a" in * (glob) (no-windows !)
289 289
290 290
291 291 Test extdiff of multiple files in tmp dir:
292 292
293 293 $ hg update -C 0 > /dev/null
294 294 $ echo changed > a
295 295 $ echo changed > b
296 296 #if execbit
297 297 $ chmod +x b
298 298 #endif
299 299
300 300 Diff in working directory, before:
301 301
302 302 $ hg diff --git
303 303 diff --git a/a b/a
304 304 --- a/a
305 305 +++ b/a
306 306 @@ -1,1 +1,1 @@
307 307 -a
308 308 +changed
309 309 diff --git a/b b/b
310 310 old mode 100644 (execbit !)
311 311 new mode 100755 (execbit !)
312 312 --- a/b
313 313 +++ b/b
314 314 @@ -1,1 +1,1 @@
315 315 -b
316 316 +changed
317 317
318 318
319 319 Edit with extdiff -p:
320 320
321 321 Prepare custom diff/edit tool:
322 322
323 323 $ cat > 'diff tool.py' << EOT
324 324 > #!$PYTHON
325 325 > import time
326 326 > time.sleep(1) # avoid unchanged-timestamp problems
327 327 > open('a/a', 'ab').write(b'edited\n')
328 328 > open('a/b', 'ab').write(b'edited\n')
329 329 > EOT
330 330
331 331 #if execbit
332 332 $ chmod +x 'diff tool.py'
333 333 #endif
334 334
335 335 will change to /tmp/extdiff.TMP and populate directories a.TMP and a
336 336 and start tool
337 337
338 338 #if windows
339 339 $ cat > 'diff tool.bat' << EOF
340 340 > @"$PYTHON" "`pwd`/diff tool.py"
341 341 > EOF
342 342 $ hg extdiff -p "`pwd`/diff tool.bat"
343 343 [1]
344 344 #else
345 345 $ hg extdiff -p "`pwd`/diff tool.py"
346 346 [1]
347 347 #endif
348 348
349 349 Diff in working directory, after:
350 350
351 351 $ hg diff --git
352 352 diff --git a/a b/a
353 353 --- a/a
354 354 +++ b/a
355 355 @@ -1,1 +1,2 @@
356 356 -a
357 357 +changed
358 358 +edited
359 359 diff --git a/b b/b
360 360 old mode 100644 (execbit !)
361 361 new mode 100755 (execbit !)
362 362 --- a/b
363 363 +++ b/b
364 364 @@ -1,1 +1,2 @@
365 365 -b
366 366 +changed
367 367 +edited
368 368
369 369 Test extdiff with --option:
370 370
371 371 $ hg extdiff -p echo -o this -c 1
372 372 this "*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
373 373 this */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
374 374 [1]
375 375
376 376 $ hg falabala -o this -c 1
377 377 diffing this "*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
378 378 diffing this */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
379 379 [1]
380 380
381 381 Test extdiff's handling of options with spaces in them:
382 382
383 383 $ hg edspace -c 1
384 384 "name <user@example.com>" "*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
385 385 name <user@example.com> */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
386 386 [1]
387 387
388 388 $ hg extdiff -p echo -o "name <user@example.com>" -c 1
389 389 "name <user@example.com>" "*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
390 390 name <user@example.com> */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
391 391 [1]
392 392
393 393 Test with revsets:
394 394
395 395 $ hg extdif -p echo -c "rev(1)"
396 396 "*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
397 397 */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
398 398 [1]
399 399
400 400 $ hg extdif -p echo -r "0::1"
401 401 "*\\a.8a5febb7f867\\a" "a.34eed99112ab\\a" (glob) (windows !)
402 402 */extdiff.*/a.8a5febb7f867/a a.34eed99112ab/a (glob) (no-windows !)
403 403 [1]
404 404
405 405 Fallback to merge-tools.tool.executable|regkey
406 406 $ mkdir dir
407 407 $ cat > 'dir/tool.sh' << 'EOF'
408 408 > #!/bin/sh
409 409 > # Mimic a tool that syncs all attrs, including mtime
410 410 > cp $1/a $2/a
411 411 > touch -r $1/a $2/a
412 412 > chmod +x $2/a
413 413 > echo "** custom diff **"
414 414 > EOF
415 415 #if execbit
416 416 $ chmod +x dir/tool.sh
417 417 #endif
418 418
419 419 Windows can't run *.sh directly, so create a shim executable that can be.
420 420 Without something executable, the next hg command will try to run `tl` instead
421 421 of $tool (and fail).
422 422 #if windows
423 423 $ cat > dir/tool.bat <<EOF
424 424 > @sh -c "`pwd`/dir/tool.sh %1 %2"
425 425 > EOF
426 426 $ tool=`pwd`/dir/tool.bat
427 427 #else
428 428 $ tool=`pwd`/dir/tool.sh
429 429 #endif
430 430
431 431 $ cat a
432 432 changed
433 433 edited
434 434 $ hg --debug tl --config extdiff.tl= --config merge-tools.tl.executable=$tool
435 435 making snapshot of 2 files from rev * (glob)
436 436 a
437 437 b
438 438 making snapshot of 2 files from working directory
439 439 a
440 440 b
441 441 running '$TESTTMP/a/dir/tool.bat a.* a' in */extdiff.* (glob) (windows !)
442 442 running '$TESTTMP/a/dir/tool.sh a.* a' in */extdiff.* (glob) (no-windows !)
443 443 ** custom diff **
444 444 file changed while diffing. Overwriting: $TESTTMP/a/a (src: */extdiff.*/a/a) (glob)
445 445 cleaning up temp directory
446 446 [1]
447 447 $ cat a
448 448 a
449 449
450 450 #if execbit
451 451 $ [ -x a ]
452 452
453 453 $ cat > 'dir/tool.sh' << 'EOF'
454 454 > #!/bin/sh
455 455 > chmod -x $2/a
456 456 > echo "** custom diff **"
457 457 > EOF
458 458
459 459 $ hg --debug tl --config extdiff.tl= --config merge-tools.tl.executable=$tool
460 460 making snapshot of 2 files from rev * (glob)
461 461 a
462 462 b
463 463 making snapshot of 2 files from working directory
464 464 a
465 465 b
466 466 running '$TESTTMP/a/dir/tool.sh a.* a' in */extdiff.* (glob)
467 467 ** custom diff **
468 468 file changed while diffing. Overwriting: $TESTTMP/a/a (src: */extdiff.*/a/a) (glob)
469 469 cleaning up temp directory
470 470 [1]
471 471
472 472 $ [ -x a ]
473 473 [1]
474 474 #endif
475 475
476 476 $ cd ..
477 477
478 478 #if symlink
479 479
480 480 Test symlinks handling (issue1909)
481 481
482 482 $ hg init testsymlinks
483 483 $ cd testsymlinks
484 484 $ echo a > a
485 485 $ hg ci -Am adda
486 486 adding a
487 487 $ echo a >> a
488 488 $ ln -s missing linka
489 489 $ hg add linka
490 490 $ hg falabala -r 0 --traceback
491 491 diffing testsymlinks.07f494440405 testsymlinks
492 492 [1]
493 493 $ cd ..
494 494
495 495 #endif
496 496
497 497 Test handling of non-ASCII paths in generated docstrings (issue5301)
498 498
499 499 >>> with open("u", "wb") as f:
500 500 ... n = f.write(b"\xa5\xa5")
501 501 $ U=`cat u`
502 502
503 503 $ HGPLAIN=1 hg --config hgext.extdiff= --config extdiff.cmd.td=hi help -k xyzzy
504 504 abort: no matches
505 505 (try 'hg help' for a list of topics)
506 506 [255]
507 507
508 508 $ HGPLAIN=1 hg --config hgext.extdiff= --config extdiff.cmd.td=hi help td > /dev/null
509 509
510 510 $ LC_MESSAGES=ja_JP.UTF-8 hg --config hgext.extdiff= --config extdiff.cmd.td=$U help -k xyzzy
511 511 abort: no matches
512 512 (try 'hg help' for a list of topics)
513 513 [255]
514 514
515 515 $ LC_MESSAGES=ja_JP.UTF-8 hg --config hgext.extdiff= --config extdiff.cmd.td=$U help td \
516 516 > | grep "^ '"
517 517 '\xa5\xa5'
518 518
519 519 $ cd $TESTTMP
520 520
521 521 Test that diffing a single file works, even if that file is new
522 522
523 523 $ hg init testsinglefile
524 524 $ cd testsinglefile
525 525 $ echo a > a
526 526 $ hg add a
527 527 $ hg falabala
528 528 diffing nul "*\\a" (glob) (windows !)
529 529 diffing /dev/null */a (glob) (no-windows !)
530 530 [1]
531 531 $ hg ci -qm a
532 532 $ hg falabala -c .
533 533 diffing nul "*\\a" (glob) (windows !)
534 534 diffing /dev/null */a (glob) (no-windows !)
535 535 [1]
536 536 $ echo a >> a
537 537 $ hg falabala
538 538 diffing "*\\a" "*\\a" (glob) (windows !)
539 539 diffing */a */a (glob) (no-windows !)
540 540 [1]
541 541 $ hg ci -qm 2a
542 542 $ hg falabala -c .
543 543 diffing "*\\a" "*\\a" (glob) (windows !)
544 544 diffing */a */a (glob) (no-windows !)
545 545 [1]
General Comments 0
You need to be logged in to leave comments. Login now