sapling/eden/hg-server/tests/test-dispatch.t
Durham Goode 98d9269874 server: copy hg to a new hg-server directory
Summary:
Create a fork of the Mercurial code that we can use to build server
rpms. The hg servers will continue to exist for a few more months while we move
the darkstorm and ediscovery use cases off them. In the mean time, we want to
start making breaking changes to the client, so let's create a stable copy of
the hg code to produce rpms for the hg servers.

The fork is based off c7770c78d, the latest hg release.

This copies the files as is, then adds some minor tweaks to get it to build:
- Disables some lint checks that appear to be bypassed by path
- sed replace eden/scm with eden/hg-server
- Removed a dependency on scm/telemetry from the edenfs-client tests since
  scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts
  with the hg-server conflict parser.

allow-large-files

Reviewed By: quark-zju

Differential Revision: D27632557

fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
2021-04-09 10:09:06 -07:00

171 lines
4.1 KiB
Perl

#chg-compatible
$ disable treemanifest
test command parsing and dispatch
$ hg init a
$ cd a
Redundant options used to crash (issue436):
$ hg -v log -v
$ hg -v log -v x
$ echo a > a
$ hg ci -Ama
adding a
Missing arg:
$ hg cat
hg cat: invalid arguments
(use 'hg cat -h' to get help)
[255]
Missing parameter for early option:
$ hg log -R 2>&1 | grep 'hg log'
hg log: option -R requires argument
(use 'hg log -h' to get help)
"--" may be an option value:
$ hg -R -- log
abort: repository -- not found!
[255]
$ hg log -R --
abort: repository -- not found!
[255]
$ hg log -T --
-- (no-eol)
$ hg log -T -- -k nomatch
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]
Unparsable form of early options:
$ hg cat --debugg
abort: option --debugger may not be abbreviated!
[255]
Parsing failure of early options should be detected before executing the
command:
$ hg log -b '--config=hooks.pre-log=false' default
abort: option --config may not be abbreviated!
[255]
$ hg log -b -R. default
abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
[255]
$ hg log --cwd .. -b --cwd=. default
abort: option --cwd may not be abbreviated!
[255]
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
warning: extension bad is disabled because it cannot be imported from bad.py: bad
abort: option --config may not be abbreviated!
[255]
$ mkdir -p badrepo/.hg
$ echo 'invalid-syntax' > badrepo/.hg/hgrc
$ hg log -b -Rbadrepo default
abort: unable to read repo config to get repo name
[255]
(XXX: Rust io::Error does not contain path information)
$ hg log -b --cwd=inexistent default
abort: $ENOENT$ (os error *) (glob)
[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'
abort: option --config may not be abbreviated!
[255]
$ hg log -b '--config=defaults.log=--config=hooks.pre-log=false'
abort: option --config may not be abbreviated!
[255]
XXX: Should we support this?
Shell aliases bypass any command parsing rules but for the early one:
$ hg log -b '--config=alias.log=!echo howdy'
abort: option --config may not be abbreviated!
[255]
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
[255]
$ HGPLAINEXCEPT= hg log --cwd .. -q -Ra -b default
cb9a9f314b8b
[defaults]
$ hg cat a
a
$ cat >> $HGRCPATH <<EOF
> [defaults]
> cat = -r null
> EOF
$ hg cat a
a: no such file in rev 000000000000
[1]
$ cd "$TESTTMP"
OSError "No such file or directory" / "The system cannot find the path
specified" should include filename even when it is empty
$ hg -R a archive ''
abort:* (glob)
[255]
#if no-outer-repo
No repo:
$ hg cat
abort: '$TESTTMP' is not inside a repository, but this command requires a repository!
(use 'cd' to go to a directory inside a repository and try again)
[255]
#endif
#if rmcwd
Current directory removed:
$ mkdir $TESTTMP/repo1
$ cd $TESTTMP/repo1
$ rm -rf $TESTTMP/repo1
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)
sh: 0: getcwd() failed: $ENOENT$
Since the exact behavior depends on the shell, only check it returns non-zero.
$ HGDEMANDIMPORT=disable hg version -q 2>/dev/null || false
[1]
#endif