mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 01:07:15 +03:00
2dc2a3d2a2
Summary:
CommandError happens if there is an unknown command flag, or a required
argument is missing. The old behavior is to print an error message to
stderr, then start the pager with the command help printed to stdout.
There are 2 problems with that approach:
1. When using mosh, a long help text might flush the actual error to out of the
screen. The error message will be missed.
2. When captured in shell scripts, the help text printed to stdout would be
captured, which is almost always undesirable.
The actual motivation of this change is for 2. Zsh themes like bullet-train [1]
uses `hg id -b 2>/dev/null` and we'd like to remove `id -b` support. After that,
the command should not polluate stdout with help text.
[1]: bd88ade263/bullet-train.zsh-theme (L102)
Differential Revision: D14151200
fbshipit-source-id: edd38e91115f96929438379aa2e40edfba560b41
45 lines
1.2 KiB
Perl
45 lines
1.2 KiB
Perl
$ hg init repo
|
|
$ cd repo
|
|
|
|
Empty
|
|
$ hg log --configfile | head -1
|
|
hg log: option --configfile requires argument
|
|
(use 'hg log -h' to get help)
|
|
|
|
Simple file
|
|
$ cat >> $TESTTMP/simple.rc <<EOF
|
|
> [mysection]
|
|
> myname = myvalue
|
|
> EOF
|
|
$ hg config --configfile $TESTTMP/simple.rc mysection
|
|
mysection.myname=myvalue
|
|
|
|
RC file that includes another
|
|
$ cat >> $TESTTMP/include.rc <<EOF
|
|
> [includesection]
|
|
> includename = includevalue
|
|
> EOF
|
|
$ cat >> $TESTTMP/simple.rc <<EOF
|
|
> %include $TESTTMP/include.rc
|
|
> EOF
|
|
$ hg config --configfile $TESTTMP/simple.rc includesection
|
|
includesection.includename=includevalue
|
|
|
|
Order matters
|
|
$ cat >> $TESTTMP/other.rc <<EOF
|
|
> [mysection]
|
|
> myname = othervalue
|
|
> EOF
|
|
$ hg config --configfile $TESTTMP/other.rc --configfile $TESTTMP/simple.rc mysection
|
|
mysection.myname=myvalue
|
|
$ hg config --configfile $TESTTMP/simple.rc --configfile $TESTTMP/other.rc mysection
|
|
mysection.myname=othervalue
|
|
|
|
Order relative to --config
|
|
$ hg config --configfile $TESTTMP/simple.rc --config mysection.myname=manualvalue mysection
|
|
mysection.myname=manualvalue
|
|
|
|
Attribution works
|
|
$ hg config --configfile $TESTTMP/simple.rc mysection --debug
|
|
$TESTTMP/simple.rc:2: mysection.myname=myvalue
|