##// END OF EJS Templates
hg.bat: return exit code explicitly for indirect invocation...
FUJIWARA Katsunori -
r23934:975c4fc4 stable
parent child Browse files
Show More
@@ -1,17 +1,19 b''
1 1 @echo off
2 2 rem Windows Driver script for Mercurial
3 3
4 4 setlocal
5 5 set HG=%~f0
6 6
7 7 rem Use a full path to Python (relative to this script) if it exists,
8 8 rem as the standard Python install does not put python.exe on the PATH...
9 9 rem Otherwise, expect that python.exe can be found on the PATH.
10 10 rem %~dp0 is the directory of this script
11 11
12 12 if exist "%~dp0..\python.exe" (
13 13 "%~dp0..\python" "%~dp0hg" %*
14 14 ) else (
15 15 python "%~dp0hg" %*
16 16 )
17 17 endlocal
18
19 exit /b %ERRORLEVEL%
@@ -1,527 +1,536 b''
1 1 $ HGFOO=BAR; export HGFOO
2 2 $ cat >> $HGRCPATH <<EOF
3 3 > [alias]
4 4 > # should clobber ci but not commit (issue2993)
5 5 > ci = version
6 6 > myinit = init
7 7 > mycommit = commit
8 8 > optionalrepo = showconfig alias.myinit
9 9 > cleanstatus = status -c
10 10 > unknown = bargle
11 11 > ambiguous = s
12 12 > recursive = recursive
13 13 > disabled = email
14 14 > nodefinition =
15 15 > noclosingquotation = '
16 16 > no--cwd = status --cwd elsewhere
17 17 > no-R = status -R elsewhere
18 18 > no--repo = status --repo elsewhere
19 19 > no--repository = status --repository elsewhere
20 20 > no--config = status --config a.config=1
21 21 > mylog = log
22 22 > lognull = log -r null
23 23 > shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
24 24 > positional = log --template '{\$2} {\$1} | {date|isodate}\n'
25 25 > dln = lognull --debug
26 26 > nousage = rollback
27 27 > put = export -r 0 -o "\$FOO/%R.diff"
28 28 > blank = !printf '\n'
29 29 > self = !printf '\$0\n'
30 30 > echoall = !printf '\$@\n'
31 31 > echo1 = !printf '\$1\n'
32 32 > echo2 = !printf '\$2\n'
33 33 > echo13 = !printf '\$1 \$3\n'
34 34 > echotokens = !printf "%s\n" "\$@"
35 35 > count = !hg log -r "\$@" --template=. | wc -c | sed -e 's/ //g'
36 36 > mcount = !hg log \$@ --template=. | wc -c | sed -e 's/ //g'
37 37 > rt = root
38 38 > tglog = log -G --template "{rev}:{node|short}: '{desc}' {branches}\n"
39 39 > idalias = id
40 40 > idaliaslong = id
41 41 > idaliasshell = !echo test
42 42 > parentsshell1 = !echo one
43 43 > parentsshell2 = !echo two
44 44 > escaped1 = !printf 'test\$\$test\n'
45 45 > escaped2 = !sh -c 'echo "HGFOO is \$\$HGFOO"'
46 46 > escaped3 = !sh -c 'echo "\$1 is \$\$\$1"'
47 47 > escaped4 = !printf '\$\$0 \$\$@\n'
48 48 > exit1 = !sh -c 'exit 1'
49 49 >
50 50 > [defaults]
51 51 > mylog = -q
52 52 > lognull = -q
53 53 > log = -v
54 54 > EOF
55 55
56 56
57 57 basic
58 58
59 59 $ hg myinit alias
60 60
61 61
62 62 unknown
63 63
64 64 $ hg unknown
65 65 abort: alias 'unknown' resolves to unknown command 'bargle'
66 66 [255]
67 67 $ hg help unknown
68 68 alias 'unknown' resolves to unknown command 'bargle'
69 69
70 70
71 71 ambiguous
72 72
73 73 $ hg ambiguous
74 74 abort: alias 'ambiguous' resolves to ambiguous command 's'
75 75 [255]
76 76 $ hg help ambiguous
77 77 alias 'ambiguous' resolves to ambiguous command 's'
78 78
79 79
80 80 recursive
81 81
82 82 $ hg recursive
83 83 abort: alias 'recursive' resolves to unknown command 'recursive'
84 84 [255]
85 85 $ hg help recursive
86 86 alias 'recursive' resolves to unknown command 'recursive'
87 87
88 88
89 89 disabled
90 90
91 91 $ hg disabled
92 92 abort: alias 'disabled' resolves to unknown command 'email'
93 93 ('email' is provided by 'patchbomb' extension)
94 94 [255]
95 95 $ hg help disabled
96 96 alias 'disabled' resolves to unknown command 'email'
97 97
98 98 'email' is provided by the following extension:
99 99
100 100 patchbomb command to send changesets as (a series of) patch emails
101 101
102 102 (use "hg help extensions" for information on enabling extensions)
103 103
104 104
105 105 no definition
106 106
107 107 $ hg nodef
108 108 abort: no definition for alias 'nodefinition'
109 109 [255]
110 110 $ hg help nodef
111 111 no definition for alias 'nodefinition'
112 112
113 113
114 114 no closing quotation
115 115
116 116 $ hg noclosing
117 117 abort: error in definition for alias 'noclosingquotation': No closing quotation
118 118 [255]
119 119 $ hg help noclosing
120 120 error in definition for alias 'noclosingquotation': No closing quotation
121 121
122 122
123 123 invalid options
124 124
125 125 $ hg no--cwd
126 126 abort: error in definition for alias 'no--cwd': --cwd may only be given on the command line
127 127 [255]
128 128 $ hg help no--cwd
129 129 error in definition for alias 'no--cwd': --cwd may only be given on the
130 130 command line
131 131 $ hg no-R
132 132 abort: error in definition for alias 'no-R': -R may only be given on the command line
133 133 [255]
134 134 $ hg help no-R
135 135 error in definition for alias 'no-R': -R may only be given on the command line
136 136 $ hg no--repo
137 137 abort: error in definition for alias 'no--repo': --repo may only be given on the command line
138 138 [255]
139 139 $ hg help no--repo
140 140 error in definition for alias 'no--repo': --repo may only be given on the
141 141 command line
142 142 $ hg no--repository
143 143 abort: error in definition for alias 'no--repository': --repository may only be given on the command line
144 144 [255]
145 145 $ hg help no--repository
146 146 error in definition for alias 'no--repository': --repository may only be given
147 147 on the command line
148 148 $ hg no--config
149 149 abort: error in definition for alias 'no--config': --config may only be given on the command line
150 150 [255]
151 151
152 152 optional repository
153 153
154 154 #if no-outer-repo
155 155 $ hg optionalrepo
156 156 init
157 157 #endif
158 158 $ cd alias
159 159 $ cat > .hg/hgrc <<EOF
160 160 > [alias]
161 161 > myinit = init -q
162 162 > EOF
163 163 $ hg optionalrepo
164 164 init -q
165 165
166 166 no usage
167 167
168 168 $ hg nousage
169 169 no rollback information available
170 170 [1]
171 171
172 172 $ echo foo > foo
173 173 $ hg commit -Amfoo
174 174 adding foo
175 175
176 176
177 177 with opts
178 178
179 179 $ hg cleanst
180 180 C foo
181 181
182 182
183 183 with opts and whitespace
184 184
185 185 $ hg shortlog
186 186 0 e63c23eaa88a | 1970-01-01 00:00 +0000
187 187
188 188 positional arguments
189 189
190 190 $ hg positional
191 191 abort: too few arguments for command alias
192 192 [255]
193 193 $ hg positional a
194 194 abort: too few arguments for command alias
195 195 [255]
196 196 $ hg positional 'node|short' rev
197 197 0 e63c23eaa88a | 1970-01-01 00:00 +0000
198 198
199 199 interaction with defaults
200 200
201 201 $ hg mylog
202 202 0:e63c23eaa88a
203 203 $ hg lognull
204 204 -1:000000000000
205 205
206 206
207 207 properly recursive
208 208
209 209 $ hg dln
210 210 changeset: -1:0000000000000000000000000000000000000000
211 211 phase: public
212 212 parent: -1:0000000000000000000000000000000000000000
213 213 parent: -1:0000000000000000000000000000000000000000
214 214 manifest: -1:0000000000000000000000000000000000000000
215 215 user:
216 216 date: Thu Jan 01 00:00:00 1970 +0000
217 217 extra: branch=default
218 218
219 219
220 220
221 221 path expanding
222 222
223 223 $ FOO=`pwd` hg put
224 224 $ cat 0.diff
225 225 # HG changeset patch
226 226 # User test
227 227 # Date 0 0
228 228 # Thu Jan 01 00:00:00 1970 +0000
229 229 # Node ID e63c23eaa88ae77967edcf4ea194d31167c478b0
230 230 # Parent 0000000000000000000000000000000000000000
231 231 foo
232 232
233 233 diff -r 000000000000 -r e63c23eaa88a foo
234 234 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
235 235 +++ b/foo Thu Jan 01 00:00:00 1970 +0000
236 236 @@ -0,0 +1,1 @@
237 237 +foo
238 238
239 239
240 240 simple shell aliases
241 241
242 242 $ hg blank
243 243
244 244 $ hg blank foo
245 245
246 246 $ hg self
247 247 self
248 248 $ hg echoall
249 249
250 250 $ hg echoall foo
251 251 foo
252 252 $ hg echoall 'test $2' foo
253 253 test $2 foo
254 254 $ hg echoall 'test $@' foo '$@'
255 255 test $@ foo $@
256 256 $ hg echoall 'test "$@"' foo '"$@"'
257 257 test "$@" foo "$@"
258 258 $ hg echo1 foo bar baz
259 259 foo
260 260 $ hg echo2 foo bar baz
261 261 bar
262 262 $ hg echo13 foo bar baz test
263 263 foo baz
264 264 $ hg echo2 foo
265 265
266 266 $ hg echotokens
267 267
268 268 $ hg echotokens foo 'bar $1 baz'
269 269 foo
270 270 bar $1 baz
271 271 $ hg echotokens 'test $2' foo
272 272 test $2
273 273 foo
274 274 $ hg echotokens 'test $@' foo '$@'
275 275 test $@
276 276 foo
277 277 $@
278 278 $ hg echotokens 'test "$@"' foo '"$@"'
279 279 test "$@"
280 280 foo
281 281 "$@"
282 282 $ echo bar > bar
283 283 $ hg commit -qA -m bar
284 284 $ hg count .
285 285 1
286 286 $ hg count 'branch(default)'
287 287 2
288 288 $ hg mcount -r '"branch(default)"'
289 289 2
290 290
291 291 $ hg tglog
292 292 @ 1:042423737847: 'bar'
293 293 |
294 294 o 0:e63c23eaa88a: 'foo'
295 295
296 296
297 297
298 298 shadowing
299 299
300 300 $ hg i
301 301 hg: command 'i' is ambiguous:
302 302 idalias idaliaslong idaliasshell identify import incoming init
303 303 [255]
304 304 $ hg id
305 305 042423737847 tip
306 306 $ hg ida
307 307 hg: command 'ida' is ambiguous:
308 308 idalias idaliaslong idaliasshell
309 309 [255]
310 310 $ hg idalias
311 311 042423737847 tip
312 312 $ hg idaliasl
313 313 042423737847 tip
314 314 $ hg idaliass
315 315 test
316 316 $ hg parentsshell
317 317 hg: command 'parentsshell' is ambiguous:
318 318 parentsshell1 parentsshell2
319 319 [255]
320 320 $ hg parentsshell1
321 321 one
322 322 $ hg parentsshell2
323 323 two
324 324
325 325
326 326 shell aliases with global options
327 327
328 328 $ hg init sub
329 329 $ cd sub
330 330 $ hg count 'branch(default)'
331 331 abort: unknown revision 'default'!
332 332 0
333 333 $ hg -v count 'branch(default)'
334 334 abort: unknown revision 'default'!
335 335 0
336 336 $ hg -R .. count 'branch(default)'
337 337 abort: unknown revision 'default'!
338 338 0
339 339 $ hg --cwd .. count 'branch(default)'
340 340 2
341 341 $ hg echoall --cwd ..
342 342
343 343
344 344
345 345 repo specific shell aliases
346 346
347 347 $ cat >> .hg/hgrc <<EOF
348 348 > [alias]
349 349 > subalias = !echo sub
350 350 > EOF
351 351 $ cat >> ../.hg/hgrc <<EOF
352 352 > [alias]
353 353 > mainalias = !echo main
354 354 > EOF
355 355
356 356
357 357 shell alias defined in current repo
358 358
359 359 $ hg subalias
360 360 sub
361 361 $ hg --cwd .. subalias > /dev/null
362 362 hg: unknown command 'subalias'
363 363 [255]
364 364 $ hg -R .. subalias > /dev/null
365 365 hg: unknown command 'subalias'
366 366 [255]
367 367
368 368
369 369 shell alias defined in other repo
370 370
371 371 $ hg mainalias > /dev/null
372 372 hg: unknown command 'mainalias'
373 373 [255]
374 374 $ hg -R .. mainalias
375 375 main
376 376 $ hg --cwd .. mainalias
377 377 main
378 378
379 379
380 380 shell aliases with escaped $ chars
381 381
382 382 $ hg escaped1
383 383 test$test
384 384 $ hg escaped2
385 385 HGFOO is BAR
386 386 $ hg escaped3 HGFOO
387 387 HGFOO is BAR
388 388 $ hg escaped4 test
389 389 $0 $@
390 390
391 391 abbreviated name, which matches against both shell alias and the
392 392 command provided extension, should be aborted.
393 393
394 394 $ cat >> .hg/hgrc <<EOF
395 395 > [extensions]
396 396 > hgext.rebase =
397 397 > EOF
398 398 #if windows
399 399 $ cat >> .hg/hgrc <<EOF
400 400 > [alias]
401 401 > rebate = !echo this is %HG_ARGS%
402 402 > EOF
403 403 #else
404 404 $ cat >> .hg/hgrc <<EOF
405 405 > [alias]
406 406 > rebate = !echo this is \$HG_ARGS
407 407 > EOF
408 408 #endif
409 409 $ hg reba
410 410 hg: command 'reba' is ambiguous:
411 411 rebase rebate
412 412 [255]
413 413 $ hg rebat
414 414 this is rebate
415 415 $ hg rebat --foo-bar
416 416 this is rebate --foo-bar
417 417
418 418 invalid arguments
419 419
420 420 $ hg rt foo
421 421 hg rt: invalid arguments
422 422 hg rt
423 423
424 424 alias for: hg root
425 425
426 426 (use "hg rt -h" to show more help)
427 427 [255]
428 428
429 429 invalid global arguments for normal commands, aliases, and shell aliases
430 430
431 431 $ hg --invalid root
432 432 hg: option --invalid not recognized
433 433 Mercurial Distributed SCM
434 434
435 435 basic commands:
436 436
437 437 add add the specified files on the next commit
438 438 annotate show changeset information by line for each file
439 439 clone make a copy of an existing repository
440 440 commit commit the specified files or all outstanding changes
441 441 diff diff repository (or selected files)
442 442 export dump the header and diffs for one or more changesets
443 443 forget forget the specified files on the next commit
444 444 init create a new repository in the given directory
445 445 log show revision history of entire repository or files
446 446 merge merge another revision into working directory
447 447 pull pull changes from the specified source
448 448 push push changes to the specified destination
449 449 remove remove the specified files on the next commit
450 450 serve start stand-alone webserver
451 451 status show changed files in the working directory
452 452 summary summarize working directory state
453 453 update update working directory (or switch revisions)
454 454
455 455 (use "hg help" for the full list of commands or "hg -v" for details)
456 456 [255]
457 457 $ hg --invalid mylog
458 458 hg: option --invalid not recognized
459 459 Mercurial Distributed SCM
460 460
461 461 basic commands:
462 462
463 463 add add the specified files on the next commit
464 464 annotate show changeset information by line for each file
465 465 clone make a copy of an existing repository
466 466 commit commit the specified files or all outstanding changes
467 467 diff diff repository (or selected files)
468 468 export dump the header and diffs for one or more changesets
469 469 forget forget the specified files on the next commit
470 470 init create a new repository in the given directory
471 471 log show revision history of entire repository or files
472 472 merge merge another revision into working directory
473 473 pull pull changes from the specified source
474 474 push push changes to the specified destination
475 475 remove remove the specified files on the next commit
476 476 serve start stand-alone webserver
477 477 status show changed files in the working directory
478 478 summary summarize working directory state
479 479 update update working directory (or switch revisions)
480 480
481 481 (use "hg help" for the full list of commands or "hg -v" for details)
482 482 [255]
483 483 $ hg --invalid blank
484 484 hg: option --invalid not recognized
485 485 Mercurial Distributed SCM
486 486
487 487 basic commands:
488 488
489 489 add add the specified files on the next commit
490 490 annotate show changeset information by line for each file
491 491 clone make a copy of an existing repository
492 492 commit commit the specified files or all outstanding changes
493 493 diff diff repository (or selected files)
494 494 export dump the header and diffs for one or more changesets
495 495 forget forget the specified files on the next commit
496 496 init create a new repository in the given directory
497 497 log show revision history of entire repository or files
498 498 merge merge another revision into working directory
499 499 pull pull changes from the specified source
500 500 push push changes to the specified destination
501 501 remove remove the specified files on the next commit
502 502 serve start stand-alone webserver
503 503 status show changed files in the working directory
504 504 summary summarize working directory state
505 505 update update working directory (or switch revisions)
506 506
507 507 (use "hg help" for the full list of commands or "hg -v" for details)
508 508 [255]
509 509
510 510 This should show id:
511 511
512 512 $ hg --config alias.log='id' log
513 513 000000000000 tip
514 514
515 515 This shouldn't:
516 516
517 517 $ hg --config alias.log='id' history
518 518
519 519 $ cd ../..
520 520
521 521 return code of command and shell aliases:
522 522
523 523 $ hg mycommit -R alias
524 524 nothing changed
525 525 [1]
526 526 $ hg exit1
527 527 [1]
528
529 #if no-outer-repo
530 $ hg root
531 abort: no repository found in '$TESTTMP' (.hg not found)!
532 [255]
533 $ hg --config alias.hgroot='!hg root' hgroot
534 abort: no repository found in '$TESTTMP' (.hg not found)!
535 [255]
536 #endif
General Comments 0
You need to be logged in to leave comments. Login now