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