sapling/eden/scm/tests/test-subcommands.t

278 lines
7.4 KiB
Perl
Raw Normal View History

#require py2
#chg-compatible
$ newext testcommands <<EOF
> from edenscm.mercurial import registrar
> cmdtable = {}
> command = registrar.command(cmdtable)
> @command('test', [], 'hg test SUBCOMMAND', subonly=True)
> def test(ui, repo):
> """test command"""
> ui.status("test command called (should not happen)\n")
> subcmd = test.subcommand(categories=[("First Category", ["one"])])
> @subcmd('one', [])
> def testone(ui, repo):
> """first test subcommand"""
> ui.status("test subcommand one called\n")
> @subcmd('two', [])
> def testone(ui, repo):
> """second test subcommand"""
> ui.status("test subcommand two called\n")
> @command('othertest', [], 'hg othertest [SUBCOMMAND]')
> def othertest(ui, repo, parameter):
> """other test command"""
> ui.status("other test command called with '%s'\n" % parameter)
> othersubcmd = othertest.subcommand()
> @othersubcmd('alpha|alfa', [])
> def othertestalpha(ui, repo, parameter):
> """other test subcommand alpha"""
> ui.status("other test command alpha called with '%s'\n" % parameter)
> nestedsubcmd = othertestalpha.subcommand()
> @nestedsubcmd('beta', [])
> def othertestalphabeta(ui, repo):
> """other test subcommand alpha subcommand beta"""
> ui.status("other test command alpha/beta called\n")
> EOF
$ readconfig <<EOF
> [alias]
> xt = test
> xt1 = test one
> xt0 = test nonexistent
> yt = othertest
> yta = othertest alpha
> ytf = othertest foo
> EOF
$ hg init
$ hg test
hg test: subcommand required
[255]
$ hg test one
test subcommand one called
$ hg test two
test subcommand two called
$ hg test nonexistent
hg test: unknown subcommand 'nonexistent'
[255]
$ hg tes o
unknown command 'tes'
(use 'hg help' to get help)
[255]
$ hg xt
hg test: subcommand required
[255]
$ hg xt one
test subcommand one called
$ hg xt too
hg test: unknown subcommand 'too'
[255]
$ hg xt1
test subcommand one called
$ hg xt0
hg test: unknown subcommand 'nonexistent'
[255]
$ hg othertest
hg othertest: invalid arguments
(use 'hg othertest -h' to get help)
[255]
$ hg othertest foo
other test command called with 'foo'
$ hg othertest alpha
hg othertest alpha: invalid arguments
(use 'hg othertest alpha -h' to get help)
[255]
$ hg othertest alfa foo
other test command alpha called with 'foo'
$ hg othertest alpha beta
other test command alpha/beta called
$ hg yt
hg othertest: invalid arguments
(use 'hg othertest -h' to get help)
[255]
$ hg yta foo
other test command alpha called with 'foo'
$ hg ytf
other test command called with 'foo'
$ hg help test
hg test SUBCOMMAND
test command
First Category:
one first test subcommand
Other Subcommands:
two second test subcommand
(use 'hg help test SUBCOMMAND' to show complete subcommand help)
(some details hidden, use --verbose to show complete help)
$ hg help test --quiet
hg test SUBCOMMAND
test command
First Category:
one first test subcommand
Other Subcommands:
two second test subcommand
$ hg help test one
hg test one
first test subcommand
(some details hidden, use --verbose to show complete help)
$ hg help test one --quiet
hg test one
first test subcommand
$ hg help test two --verbose
hg test two
second test subcommand
Global options ([+] can be repeated):
-R --repository REPO repository root directory or name of overlay bundle
file
--cwd DIR change working directory
-y --noninteractive do not prompt, automatically pick the first choice
for all prompts
-q --quiet suppress output
-v --verbose enable additional output
--color TYPE when to colorize (boolean, always, auto, never, or
debug)
--config CONFIG [+] set/override config option (use
'section.name=value')
--configfile FILE [+] enables the given config file
--debug enable debugging output
--debugger start debugger
encoding: replace 'ascii' with 'utf-8' automatically Summary: `ascii` was used as the default / fallback, which is not a user-friendly choice. Nowadays utf-8 dominates: - Rust stdlib is utf-8. - Ruby since 1.9 is utf-8 by default. - Python 3 is unicode by default. - Windows 10 adds utf-8 code page. Given the fact that: - Our CI sets HGENCODING to utf-8 - Nuclide passes `--encoding=utf-8` to every command. - Some people have messed up with `LC_*` and complained about hg crashes. - utf-8 is a super set of ascii, nobody complains that they want `ascii` encoding and the `utf-8` encoding messed their setup up. Let's just use `utf-8` as the default encoding. More aggressively, if someone sets `ascii` as the encoding, it's almost always a mistake. Auto-correct that to `utf-8` too. This should also make future integration with Rust easier (where it's enforced utf-8 and does not have an option to change the encoding). In the future we might just drop the flexibility of choosing customized encoding, so this diff autofixes `ascii` to `utf-8`, instead of allowing `ascii` to be set. We cannot enforce `utf-8` yet, because of Windows. Here is our encoding strategy vs the upstream's: | item | upstream | | ours | ours | | | current | ideal | current | ideal | | CLI argv | bytes | bytes | utf-8 [1] | utf-8 | | path | bytes | auto [3] | migrating [2] | utf-8 | | commit message | utf-8 | utf-8 | utf-8 | utf-8 | | bookmark name | utf-8 | utf-8 | utf-8 | utf-8 | | file content | bytes | bytes | bytes | bytes | [1]: Argv was accidentally enforced utf-8 for command-line arguments by a Rust wrapper. But it simplified a lot of things and is kind of ok: everything that can be passed as CLI arguments are utf-8: -M commit message, -b bookmark, paths, etc. There is no "file content" passed via CLI arguments. [2]: Path is controversial, because it's possible for systems to have non-utf8 paths. The upstream behavior is incorrect if a repo gets shared among different encoding systems (ex. both Linux and Windows). We have to know the encoding of paths to be able to convert them suitable for the local system. One way is to enforce UTF-8 for paths. The other is to keep encoding information stored with individual paths (like Ruby strings). The UTF-8 approach is much simpler with the tradeoff that non-utf-8 paths become unsupported, which seems to be a reasonable trade-off. [3]: See https://www.mercurial-scm.org/wiki/WindowsUTF8Plan. Reviewed By: singhsrb Differential Revision: D17098991 fbshipit-source-id: c0ff1e586a887233bd43cdb854fb3538aa9b70c2
2019-09-13 01:05:08 +03:00
--encoding ENCODE set the charset encoding (default: utf-8)
--encodingmode MODE set the charset encoding mode (default: strict)
--traceback always print a traceback on exception
--time time how long the command takes
--profile print command execution profile
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
--pager TYPE when to paginate (boolean, always, auto, or never)
(default: auto)
$ hg help test nonexistent
abort: 'test' has no such subcommand: nonexistent
(run 'hg help test' to see available subcommands)
[255]
$ hg othertest --help --verbose
hg othertest [SUBCOMMAND]
other test command
Global options ([+] can be repeated):
-R --repository REPO repository root directory or name of overlay bundle
file
--cwd DIR change working directory
-y --noninteractive do not prompt, automatically pick the first choice
for all prompts
-q --quiet suppress output
-v --verbose enable additional output
--color TYPE when to colorize (boolean, always, auto, never, or
debug)
--config CONFIG [+] set/override config option (use
'section.name=value')
--configfile FILE [+] enables the given config file
--debug enable debugging output
--debugger start debugger
encoding: replace 'ascii' with 'utf-8' automatically Summary: `ascii` was used as the default / fallback, which is not a user-friendly choice. Nowadays utf-8 dominates: - Rust stdlib is utf-8. - Ruby since 1.9 is utf-8 by default. - Python 3 is unicode by default. - Windows 10 adds utf-8 code page. Given the fact that: - Our CI sets HGENCODING to utf-8 - Nuclide passes `--encoding=utf-8` to every command. - Some people have messed up with `LC_*` and complained about hg crashes. - utf-8 is a super set of ascii, nobody complains that they want `ascii` encoding and the `utf-8` encoding messed their setup up. Let's just use `utf-8` as the default encoding. More aggressively, if someone sets `ascii` as the encoding, it's almost always a mistake. Auto-correct that to `utf-8` too. This should also make future integration with Rust easier (where it's enforced utf-8 and does not have an option to change the encoding). In the future we might just drop the flexibility of choosing customized encoding, so this diff autofixes `ascii` to `utf-8`, instead of allowing `ascii` to be set. We cannot enforce `utf-8` yet, because of Windows. Here is our encoding strategy vs the upstream's: | item | upstream | | ours | ours | | | current | ideal | current | ideal | | CLI argv | bytes | bytes | utf-8 [1] | utf-8 | | path | bytes | auto [3] | migrating [2] | utf-8 | | commit message | utf-8 | utf-8 | utf-8 | utf-8 | | bookmark name | utf-8 | utf-8 | utf-8 | utf-8 | | file content | bytes | bytes | bytes | bytes | [1]: Argv was accidentally enforced utf-8 for command-line arguments by a Rust wrapper. But it simplified a lot of things and is kind of ok: everything that can be passed as CLI arguments are utf-8: -M commit message, -b bookmark, paths, etc. There is no "file content" passed via CLI arguments. [2]: Path is controversial, because it's possible for systems to have non-utf8 paths. The upstream behavior is incorrect if a repo gets shared among different encoding systems (ex. both Linux and Windows). We have to know the encoding of paths to be able to convert them suitable for the local system. One way is to enforce UTF-8 for paths. The other is to keep encoding information stored with individual paths (like Ruby strings). The UTF-8 approach is much simpler with the tradeoff that non-utf-8 paths become unsupported, which seems to be a reasonable trade-off. [3]: See https://www.mercurial-scm.org/wiki/WindowsUTF8Plan. Reviewed By: singhsrb Differential Revision: D17098991 fbshipit-source-id: c0ff1e586a887233bd43cdb854fb3538aa9b70c2
2019-09-13 01:05:08 +03:00
--encoding ENCODE set the charset encoding (default: utf-8)
--encodingmode MODE set the charset encoding mode (default: strict)
--traceback always print a traceback on exception
--time time how long the command takes
--profile print command execution profile
--version output version information and exit
-h --help display help and exit
--hidden consider hidden changesets
--pager TYPE when to paginate (boolean, always, auto, or never)
(default: auto)
Subcommands:
alpha, alfa other test subcommand alpha
(use 'hg help othertest SUBCOMMAND' to show complete subcommand help)
$ hg help xt
alias for: test
hg test SUBCOMMAND
test command
First Category:
one first test subcommand
Other Subcommands:
two second test subcommand
(use 'hg help test SUBCOMMAND' to show complete subcommand help)
(some details hidden, use --verbose to show complete help)
$ hg help xt one
alias for: test one
hg test one
first test subcommand
(some details hidden, use --verbose to show complete help)
$ hg help xt1
alias for: test one
hg test one
first test subcommand
(some details hidden, use --verbose to show complete help)
$ hg othertest alpha beta --help
hg othertest alpha beta
other test subcommand alpha subcommand beta
(some details hidden, use --verbose to show complete help)