##// END OF EJS Templates
error: use detailed exit code 10 for command errors...
Martin von Zweigbergk -
r46888:9c9e0b4b default
parent child Browse files
Show More
@@ -470,14 +470,17 b' def _callcatch(ui, func):'
470 470 config parsing and commands. besides, use handlecommandexception to handle
471 471 uncaught exceptions.
472 472 """
473 detailed_exit_code = -1
473 474 try:
474 475 return scmutil.callcatch(ui, func)
475 476 except error.AmbiguousCommand as inst:
477 detailed_exit_code = 10
476 478 ui.warn(
477 479 _(b"hg: command '%s' is ambiguous:\n %s\n")
478 480 % (inst.prefix, b" ".join(inst.matches))
479 481 )
480 482 except error.CommandError as inst:
483 detailed_exit_code = 10
481 484 if inst.command:
482 485 ui.pager(b'help')
483 486 msgbytes = pycompat.bytestr(inst.message)
@@ -487,6 +490,7 b' def _callcatch(ui, func):'
487 490 ui.warn(_(b"hg: %s\n") % inst.message)
488 491 ui.warn(_(b"(use 'hg help -v' for a list of global options)\n"))
489 492 except error.UnknownCommand as inst:
493 detailed_exit_code = 10
490 494 nocmdmsg = _(b"hg: unknown command '%s'\n") % inst.command
491 495 try:
492 496 # check if the command is in a disabled extension
@@ -515,7 +519,10 b' def _callcatch(ui, func):'
515 519 if not handlecommandexception(ui):
516 520 raise
517 521
518 return -1
522 if ui.configbool(b'ui', b'detailed-exit-code'):
523 return detailed_exit_code
524 else:
525 return -1
519 526
520 527
521 528 def aliasargs(fn, givenargs):
@@ -468,13 +468,13 b' shadowing'
468 468 $ hg i
469 469 hg: command 'i' is ambiguous:
470 470 idalias idaliaslong idaliasshell identify import incoming init
471 [255]
471 [10]
472 472 $ hg id
473 473 042423737847 tip
474 474 $ hg ida
475 475 hg: command 'ida' is ambiguous:
476 476 idalias idaliaslong idaliasshell
477 [255]
477 [10]
478 478 $ hg idalias
479 479 042423737847 tip
480 480 $ hg idaliasl
@@ -484,7 +484,7 b' shadowing'
484 484 $ hg parentsshell
485 485 hg: command 'parentsshell' is ambiguous:
486 486 parentsshell1 parentsshell2
487 [255]
487 [10]
488 488 $ hg parentsshell1
489 489 one
490 490 $ hg parentsshell2
@@ -533,11 +533,11 b' shell alias defined in current repo'
533 533 $ hg --cwd .. subalias > /dev/null
534 534 hg: unknown command 'subalias'
535 535 (did you mean idalias?)
536 [255]
536 [10]
537 537 $ hg -R .. subalias > /dev/null
538 538 hg: unknown command 'subalias'
539 539 (did you mean idalias?)
540 [255]
540 [10]
541 541
542 542
543 543 shell alias defined in other repo
@@ -545,7 +545,7 b' shell alias defined in other repo'
545 545 $ hg mainalias > /dev/null
546 546 hg: unknown command 'mainalias'
547 547 (did you mean idalias?)
548 [255]
548 [10]
549 549 $ hg -R .. mainalias
550 550 main
551 551 $ hg --cwd .. mainalias
@@ -555,7 +555,7 b' typos get useful suggestions'
555 555 $ hg --cwd .. manalias
556 556 hg: unknown command 'manalias'
557 557 (did you mean one of idalias, mainalias, manifest?)
558 [255]
558 [10]
559 559
560 560 shell aliases with escaped $ chars
561 561
@@ -593,7 +593,7 b' command provided extension, should be ab'
593 593 $ hg reba
594 594 hg: command 'reba' is ambiguous:
595 595 rebase rebate
596 [255]
596 [10]
597 597 $ hg rebat
598 598 this is rebate
599 599 $ hg rebat --foo-bar
@@ -650,22 +650,22 b' invalid arguments'
650 650 -T --template TEMPLATE display with template
651 651
652 652 (use 'hg rt -h' to show more help)
653 [255]
653 [10]
654 654
655 655 invalid global arguments for normal commands, aliases, and shell aliases
656 656
657 657 $ hg --invalid root
658 658 hg: option --invalid not recognized
659 659 (use 'hg help -v' for a list of global options)
660 [255]
660 [10]
661 661 $ hg --invalid mylog
662 662 hg: option --invalid not recognized
663 663 (use 'hg help -v' for a list of global options)
664 [255]
664 [10]
665 665 $ hg --invalid blank
666 666 hg: option --invalid not recognized
667 667 (use 'hg help -v' for a list of global options)
668 [255]
668 [10]
669 669
670 670 environment variable changes in alias commands
671 671
@@ -67,12 +67,12 b' On Python 3, stdio may be None:'
67 67 $ hg unknown -q 1>&-
68 68 hg: unknown command 'unknown'
69 69 (did you mean debugknown?)
70 [255]
70 [10]
71 71
72 72 $ hg version -q 2>&-
73 73 Mercurial Distributed SCM * (glob)
74 74 $ hg unknown -q 2>&-
75 [255]
75 [10]
76 76
77 77 $ hg commit -m test
78 78
@@ -242,7 +242,7 b' Show an error if we use --options with a'
242 242 $ hg debugcomplete --options s
243 243 hg: command 's' is ambiguous:
244 244 serve shelve showconfig status summary
245 [255]
245 [10]
246 246
247 247 Show all commands + options
248 248 $ hg debugcommands
@@ -29,7 +29,7 b' Missing arg:'
29 29 -T --template TEMPLATE display with template
30 30
31 31 (use 'hg cat -h' to show more help)
32 [255]
32 [10]
33 33
34 34 Missing parameter for early option:
35 35
@@ -110,7 +110,7 b' applied before the command name is resol'
110 110 hg log: option -b not recognized
111 111 error in definition for alias 'log': --config may only be given on the command
112 112 line
113 [255]
113 [10]
114 114
115 115 $ hg log -b '--config=defaults.log=--config=hooks.pre-log=false'
116 116 abort: option --config may not be abbreviated
@@ -1018,7 +1018,7 b' Test help topic with same name as extens'
1018 1018 multirevs command
1019 1019
1020 1020 (use 'hg multirevs -h' to show more help)
1021 [255]
1021 [10]
1022 1022
1023 1023
1024 1024
@@ -1848,7 +1848,7 b' Prohibit registration of commands that d'
1848 1848 *** (use @command decorator to register 'deprecatedcmd')
1849 1849 hg: unknown command 'deprecatedcmd'
1850 1850 (use 'hg help' for a list of commands)
1851 [255]
1851 [10]
1852 1852
1853 1853 the extension shouldn't be loaded at all so the mq works:
1854 1854
@@ -1905,4 +1905,4 b' Prohibit the use of unicode strings as t'
1905 1905 *** (use b'' to make it byte string)
1906 1906 hg: unknown command 'dummy'
1907 1907 (did you mean summary?)
1908 [255]
1908 [10]
@@ -123,7 +123,7 b' config option "fastannotate.modes"'
123 123 $ hg fastannotate --config fastannotate.modes=fctx -h -q
124 124 hg: unknown command 'fastannotate'
125 125 (did you mean *) (glob)
126 [255]
126 [10]
127 127
128 128 rename
129 129
@@ -593,7 +593,7 b' Test help option with version option'
593 593 -n --dry-run do not perform actions, just print output
594 594
595 595 (use 'hg add -h' to show more help)
596 [255]
596 [10]
597 597
598 598 Test ambiguous command help
599 599
@@ -763,13 +763,13 b' Test command without options'
763 763 $ hg skjdfks
764 764 hg: unknown command 'skjdfks'
765 765 (use 'hg help' for a list of commands)
766 [255]
766 [10]
767 767
768 768 Typoed command gives suggestion
769 769 $ hg puls
770 770 hg: unknown command 'puls'
771 771 (did you mean one of pull, push?)
772 [255]
772 [10]
773 773
774 774 Not enabled extension gets suggested
775 775
@@ -780,7 +780,7 b' Not enabled extension gets suggested'
780 780 rebase command to move sets of revisions to a different ancestor
781 781
782 782 (use 'hg help extensions' for information on enabling extensions)
783 [255]
783 [10]
784 784
785 785 Disabled extension gets suggested
786 786 $ hg --config extensions.rebase=! rebase
@@ -790,7 +790,7 b' Disabled extension gets suggested'
790 790 rebase command to move sets of revisions to a different ancestor
791 791
792 792 (use 'hg help extensions' for information on enabling extensions)
793 [255]
793 [10]
794 794
795 795 Checking that help adapts based on the config:
796 796
@@ -804,16 +804,16 b' this is a section and erroring out weird'
804 804 $ hg .log
805 805 hg: unknown command '.log'
806 806 (did you mean log?)
807 [255]
807 [10]
808 808
809 809 $ hg log.
810 810 hg: unknown command 'log.'
811 811 (did you mean log?)
812 [255]
812 [10]
813 813 $ hg pu.lh
814 814 hg: unknown command 'pu.lh'
815 815 (did you mean one of pull, push?)
816 [255]
816 [10]
817 817
818 818 $ cat > helpext.py <<EOF
819 819 > import os
@@ -118,7 +118,7 b' Testing the --import-rules flag of `hg t'
118 118 web.cacerts config)
119 119
120 120 (use 'hg tracked -h' to show more help)
121 [255]
121 [10]
122 122 $ hg tracked --import-rules doesnotexist
123 123 abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$
124 124 [50]
@@ -105,7 +105,7 b' qrecord (mq not present)'
105 105 interactively record a new patch
106 106
107 107 (use 'hg qrecord -h' to show more help)
108 [255]
108 [10]
109 109
110 110 qrecord patch (mq not present)
111 111
@@ -92,7 +92,7 b' Test that extensions of source repositor'
92 92 extdiff command to allow external programs to compare revisions
93 93
94 94 (use 'hg help extensions' for information on enabling extensions)
95 [255]
95 [10]
96 96
97 97 $ echo "[extensions]" >> ../source/.hg/hgrc
98 98 $ echo "extdiff=" >> ../source/.hg/hgrc
@@ -394,7 +394,7 b' color coding of error message with curre'
394 394 $ hg unknowncommand > /dev/null
395 395 hg: unknown command 'unknowncommand'
396 396 (use 'hg help' for a list of commands)
397 [255]
397 [10]
398 398
399 399 color coding of error message without curses
400 400
@@ -402,6 +402,6 b' color coding of error message without cu'
402 402 $ PYTHONPATH=`pwd`:$PYTHONPATH hg unknowncommand > /dev/null
403 403 hg: unknown command 'unknowncommand'
404 404 (use 'hg help' for a list of commands)
405 [255]
405 [10]
406 406
407 407 $ cd ..
@@ -16,7 +16,7 b''
16 16 $ hg an a
17 17 hg: unknown command 'an'
18 18 (use 'hg help' for a list of commands)
19 [255]
19 [10]
20 20 $ hg annotate a
21 21 0: a
22 22
@@ -782,7 +782,7 b' Make sure no one adds back a -b option:'
782 782 --mq operate on patch repository
783 783
784 784 (use 'hg debugstrip -h' to show more help)
785 [255]
785 [10]
786 786
787 787 $ cd ..
788 788
General Comments 0
You need to be logged in to leave comments. Login now