test-dispatch.t
221 lines
| 5.9 KiB
| text/troff
|
Tads3Lexer
/ tests / test-dispatch.t
Adrian Buehlmann
|
r12157 | test command parsing and dispatch | ||
$ hg init a | ||||
$ cd a | ||||
Nicolas Dumazet
|
r14115 | |||
Redundant options used to crash (issue436): | ||||
$ hg -v log -v | ||||
$ hg -v log -v x | ||||
Adrian Buehlmann
|
r12157 | $ echo a > a | ||
$ hg ci -Ama | ||||
adding a | ||||
Missing arg: | ||||
$ hg cat | ||||
hg cat: invalid arguments | ||||
hg cat [OPTION]... FILE... | ||||
output the current or given revision of files | ||||
Matt Mackall
|
r22117 | options ([+] can be repeated): | ||
Adrian Buehlmann
|
r12157 | |||
Matt Mackall
|
r15145 | -o --output FORMAT print output to file with formatted name | ||
-r --rev REV print the given revision | ||||
Pierre-Yves David
|
r30152 | --decode apply any matching decode filter | ||
Matt Mackall
|
r15145 | -I --include PATTERN [+] include names matching the given patterns | ||
-X --exclude PATTERN [+] exclude names matching the given patterns | ||||
Yuya Nishihara
|
r39967 | -T --template TEMPLATE display with template | ||
Adrian Buehlmann
|
r12157 | |||
timeless
|
r29974 | (use 'hg cat -h' to show more help) | ||
Martin von Zweigbergk
|
r46888 | [10] | ||
Adrian Buehlmann
|
r12157 | |||
Yuya Nishihara
|
r35056 | Missing parameter for early option: | ||
$ hg log -R 2>&1 | grep 'hg log' | ||||
hg log: option -R requires argument | ||||
hg log [OPTION]... [FILE] | ||||
(use 'hg log -h' to show more help) | ||||
Yuya Nishihara
|
r35226 | "--" may be an option value: | ||
$ hg -R -- log | ||||
Martin von Zweigbergk
|
r46518 | abort: repository -- not found | ||
Yuya Nishihara
|
r35226 | [255] | ||
$ hg log -R -- | ||||
Martin von Zweigbergk
|
r46518 | abort: repository -- not found | ||
Yuya Nishihara
|
r35226 | [255] | ||
$ hg log -T -- | ||||
-- (no-eol) | ||||
$ hg log -T -- -k nomatch | ||||
Yuya Nishihara
|
r35056 | |||
Yuya Nishihara
|
r35058 | Parsing of early options should stop at "--": | ||
$ hg cat -- --config=hooks.pre-cat=false | ||||
--config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b | ||||
[1] | ||||
$ hg cat -- --debugger | ||||
--debugger: no such file in rev cb9a9f314b8b | ||||
[1] | ||||
Yuya Nishihara
|
r35059 | Unparsable form of early options: | ||
$ hg cat --debugg | ||||
Martin von Zweigbergk
|
r46521 | abort: option --debugger may not be abbreviated | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35059 | |||
Yuya Nishihara
|
r35063 | Parsing failure of early options should be detected before executing the | ||
command: | ||||
$ hg log -b '--config=hooks.pre-log=false' default | ||||
Martin von Zweigbergk
|
r46521 | abort: option --config may not be abbreviated | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35063 | $ hg log -b -R. default | ||
Martin von Zweigbergk
|
r46521 | abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35063 | $ hg log --cwd .. -b --cwd=. default | ||
Martin von Zweigbergk
|
r46521 | abort: option --cwd may not be abbreviated | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35063 | |||
However, we can't prevent it from loading extensions and configs: | ||||
$ cat <<EOF > bad.py | ||||
> raise Exception('bad') | ||||
> EOF | ||||
$ hg log -b '--config=extensions.bad=bad.py' default | ||||
*** failed to import extension bad from bad.py: bad | ||||
Martin von Zweigbergk
|
r46521 | abort: option --config may not be abbreviated | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35063 | |||
$ mkdir -p badrepo/.hg | ||||
$ echo 'invalid-syntax' > badrepo/.hg/hgrc | ||||
$ hg log -b -Rbadrepo default | ||||
Martin von Zweigbergk
|
r46506 | config error at badrepo/.hg/hgrc:1: invalid-syntax | ||
[30] | ||||
Yuya Nishihara
|
r35063 | |||
$ hg log -b --cwd=inexistent default | ||||
Matt Harbison
|
r35230 | abort: $ENOENT$: 'inexistent' | ||
Yuya Nishihara
|
r35063 | [255] | ||
$ hg log -b '--config=ui.traceback=yes' 2>&1 | grep '^Traceback' | ||||
Traceback (most recent call last): | ||||
$ hg log -b '--config=profiling.enabled=yes' 2>&1 | grep -i sample | ||||
Sample count: .*|No samples recorded\. (re) | ||||
Early options can't be specified in [aliases] and [defaults] because they are | ||||
applied before the command name is resolved: | ||||
$ hg log -b '--config=alias.log=log --config=hooks.pre-log=false' | ||||
hg log: option -b not recognized | ||||
error in definition for alias 'log': --config may only be given on the command | ||||
line | ||||
Martin von Zweigbergk
|
r46888 | [10] | ||
Yuya Nishihara
|
r35063 | |||
$ hg log -b '--config=defaults.log=--config=hooks.pre-log=false' | ||||
Martin von Zweigbergk
|
r46521 | abort: option --config may not be abbreviated | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35063 | |||
Shell aliases bypass any command parsing rules but for the early one: | ||||
$ hg log -b '--config=alias.log=!echo howdy' | ||||
howdy | ||||
Yuya Nishihara
|
r35180 | Early options must come first if HGPLAIN=+strictflags is specified: | ||
(BUG: chg cherry-picks early options to pass them as a server command) | ||||
#if no-chg | ||||
$ HGPLAIN=+strictflags hg log -b --config='hooks.pre-log=false' default | ||||
Martin von Zweigbergk
|
r46518 | abort: unknown revision '--config=hooks.pre-log=false' | ||
Yuya Nishihara
|
r35180 | [255] | ||
$ HGPLAIN=+strictflags hg log -b -R. default | ||||
Martin von Zweigbergk
|
r46518 | abort: unknown revision '-R.' | ||
Yuya Nishihara
|
r35180 | [255] | ||
$ HGPLAIN=+strictflags hg log -b --cwd=. default | ||||
Martin von Zweigbergk
|
r46518 | abort: unknown revision '--cwd=.' | ||
Yuya Nishihara
|
r35180 | [255] | ||
#endif | ||||
$ HGPLAIN=+strictflags hg log -b --debugger default | ||||
Martin von Zweigbergk
|
r46518 | abort: unknown revision '--debugger' | ||
Yuya Nishihara
|
r35180 | [255] | ||
$ HGPLAIN=+strictflags hg log -b --config='alias.log=!echo pwned' default | ||||
Martin von Zweigbergk
|
r46518 | abort: unknown revision '--config=alias.log=!echo pwned' | ||
Yuya Nishihara
|
r35180 | [255] | ||
$ HGPLAIN=+strictflags hg log --config='hooks.pre-log=false' -b default | ||||
Martin von Zweigbergk
|
r46521 | abort: option --config may not be abbreviated | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35180 | $ HGPLAIN=+strictflags hg log -q --cwd=.. -b default | ||
Martin von Zweigbergk
|
r46521 | abort: option --cwd may not be abbreviated | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35180 | $ HGPLAIN=+strictflags hg log -q -R . -b default | ||
Martin von Zweigbergk
|
r46521 | abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo | ||
Martin von Zweigbergk
|
r46530 | [10] | ||
Yuya Nishihara
|
r35180 | |||
$ HGPLAIN=+strictflags hg --config='hooks.pre-log=false' log -b default | ||||
abort: pre-log hook exited with status 1 | ||||
Martin von Zweigbergk
|
r47145 | [40] | ||
Yuya Nishihara
|
r35180 | $ HGPLAIN=+strictflags hg --cwd .. -q -Ra log -b default | ||
0:cb9a9f314b8b | ||||
Yuya Nishihara
|
r35223 | $ HGPLAIN=+strictflags hg --cwd .. -q --repository a log -b default | ||
0:cb9a9f314b8b | ||||
$ HGPLAIN=+strictflags hg --cwd .. -q --repo a log -b default | ||||
0:cb9a9f314b8b | ||||
Yuya Nishihara
|
r35180 | |||
For compatibility reasons, HGPLAIN=+strictflags is not enabled by plain HGPLAIN: | ||||
$ HGPLAIN= hg log --config='hooks.pre-log=false' -b default | ||||
abort: pre-log hook exited with status 1 | ||||
Martin von Zweigbergk
|
r47145 | [40] | ||
Yuya Nishihara
|
r35180 | $ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default | ||
0:cb9a9f314b8b | ||||
Adrian Buehlmann
|
r12157 | [defaults] | ||
$ hg cat a | ||||
a | ||||
$ cat >> $HGRCPATH <<EOF | ||||
> [defaults] | ||||
> cat = -r null | ||||
> EOF | ||||
$ hg cat a | ||||
a: no such file in rev 000000000000 | ||||
Matt Mackall
|
r12316 | [1] | ||
Adrian Buehlmann
|
r12157 | |||
Mads Kiilerich
|
r17014 | $ cd "$TESTTMP" | ||
Mads Kiilerich
|
r18506 | OSError "No such file or directory" / "The system cannot find the path | ||
specified" should include filename even when it is empty | ||||
Mads Kiilerich
|
r18227 | |||
$ hg -R a archive '' | ||||
Matt Harbison
|
r41430 | abort: $ENOENT$: '' (no-windows !) | ||
abort: $ENOTDIR$: '' (windows !) | ||||
Mads Kiilerich
|
r18227 | [255] | ||
Mads Kiilerich
|
r17014 | #if no-outer-repo | ||
Adrian Buehlmann
|
r12157 | No repo: | ||
$ hg cat | ||||
Martin von Zweigbergk
|
r46518 | abort: no repository found in '$TESTTMP' (.hg not found) | ||
Martin von Zweigbergk
|
r46523 | [10] | ||
Adrian Buehlmann
|
r12157 | |||
Mads Kiilerich
|
r17014 | #endif | ||
Jun Wu
|
r34644 | |||
#if rmcwd | ||||
Current directory removed: | ||||
$ mkdir $TESTTMP/repo1 | ||||
$ cd $TESTTMP/repo1 | ||||
$ rm -rf $TESTTMP/repo1 | ||||
Jun Wu
|
r34954 | |||
The output could be one of the following and something else: | ||||
chg: abort: failed to getcwd (errno = *) (glob) | ||||
abort: error getting current working directory: * (glob) | ||||
Matt Harbison
|
r35230 | sh: 0: getcwd() failed: $ENOENT$ | ||
Jun Wu
|
r34954 | Since the exact behavior depends on the shell, only check it returns non-zero. | ||
$ HGDEMANDIMPORT=disable hg version -q 2>/dev/null || false | ||||
[1] | ||||
Jun Wu
|
r34644 | |||
#endif | ||||