2019-05-28 13:12:27 +03:00
|
|
|
$ setconfig extensions.treemanifest=!
|
2010-09-02 19:13:23 +04:00
|
|
|
test command parsing and dispatch
|
|
|
|
|
|
|
|
$ hg init a
|
|
|
|
$ cd a
|
2011-04-30 19:38:06 +04:00
|
|
|
|
|
|
|
Redundant options used to crash (issue436):
|
|
|
|
$ hg -v log -v
|
|
|
|
$ hg -v log -v x
|
|
|
|
|
2010-09-02 19:13:23 +04:00
|
|
|
$ echo a > a
|
|
|
|
$ hg ci -Ama
|
|
|
|
adding a
|
|
|
|
|
|
|
|
Missing arg:
|
|
|
|
|
|
|
|
$ hg cat
|
|
|
|
hg cat: invalid arguments
|
2019-02-21 05:38:56 +03:00
|
|
|
(use 'hg cat -h' to get help)
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-09-02 19:13:23 +04:00
|
|
|
|
2017-11-11 06:09:19 +03:00
|
|
|
Missing parameter for early option:
|
|
|
|
|
|
|
|
$ hg log -R 2>&1 | grep 'hg log'
|
|
|
|
hg log: option -R requires argument
|
2019-02-21 05:38:56 +03:00
|
|
|
(use 'hg log -h' to get help)
|
2017-11-11 06:09:19 +03:00
|
|
|
|
2017-11-23 19:09:00 +03:00
|
|
|
"--" may be an option value:
|
|
|
|
|
|
|
|
$ hg -R -- log
|
2017-11-25 11:30:50 +03:00
|
|
|
abort: repository -- not found!
|
2017-11-23 19:09:00 +03:00
|
|
|
[255]
|
|
|
|
$ hg log -R --
|
2017-11-25 11:30:50 +03:00
|
|
|
abort: repository -- not found!
|
2017-11-23 19:09:00 +03:00
|
|
|
[255]
|
|
|
|
$ hg log -T --
|
|
|
|
-- (no-eol)
|
|
|
|
$ hg log -T -- -k nomatch
|
2017-11-11 06:09:19 +03:00
|
|
|
|
2017-11-10 16:27:26 +03:00
|
|
|
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]
|
|
|
|
|
2017-11-11 08:02:41 +03:00
|
|
|
Unparsable form of early options:
|
|
|
|
|
|
|
|
$ hg cat --debugg
|
|
|
|
abort: option --debugger may not be abbreviated!
|
|
|
|
[255]
|
|
|
|
|
2017-11-11 06:40:13 +03:00
|
|
|
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
|
|
|
|
*** failed to import extension bad 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
|
2018-08-24 03:41:19 +03:00
|
|
|
hg: parse error: "$TESTTMP/a/badrepo/.hg/hgrc":
|
|
|
|
--> 1:15
|
|
|
|
|
|
2019-01-16 14:49:31 +03:00
|
|
|
1 | invalid-syntax\xe2\x90\x8a (esc)
|
2018-08-24 03:41:19 +03:00
|
|
|
| ^---
|
|
|
|
|
|
|
|
|
= expected equal_sign
|
2017-11-11 06:40:13 +03:00
|
|
|
[255]
|
|
|
|
|
2019-08-21 22:57:32 +03:00
|
|
|
(XXX: Rust io::Error does not contain path information)
|
2017-11-11 06:40:13 +03:00
|
|
|
$ hg log -b --cwd=inexistent default
|
2019-08-21 22:57:32 +03:00
|
|
|
abort: $ENOENT$ (os error *) (glob)
|
2017-11-11 06:40:13 +03:00
|
|
|
[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'
|
2019-08-20 05:24:40 +03:00
|
|
|
abort: option --config may not be abbreviated!
|
2017-11-11 06:40:13 +03:00
|
|
|
[255]
|
|
|
|
|
|
|
|
$ hg log -b '--config=defaults.log=--config=hooks.pre-log=false'
|
|
|
|
abort: option --config may not be abbreviated!
|
|
|
|
[255]
|
|
|
|
|
2019-08-20 05:24:40 +03:00
|
|
|
XXX: Should we support this?
|
2017-11-11 06:40:13 +03:00
|
|
|
Shell aliases bypass any command parsing rules but for the early one:
|
|
|
|
|
|
|
|
$ hg log -b '--config=alias.log=!echo howdy'
|
2019-08-20 05:24:40 +03:00
|
|
|
abort: option --config may not be abbreviated!
|
|
|
|
[255]
|
2017-11-11 06:40:13 +03:00
|
|
|
|
2017-11-23 16:17:03 +03:00
|
|
|
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
|
|
|
|
0:cb9a9f314b8b
|
|
|
|
|
2010-09-02 19:13:23 +04:00
|
|
|
[defaults]
|
|
|
|
|
|
|
|
$ hg cat a
|
|
|
|
a
|
|
|
|
$ cat >> $HGRCPATH <<EOF
|
|
|
|
> [defaults]
|
|
|
|
> cat = -r null
|
|
|
|
> EOF
|
|
|
|
$ hg cat a
|
|
|
|
a: no such file in rev 000000000000
|
2010-09-17 02:51:32 +04:00
|
|
|
[1]
|
2010-09-02 19:13:23 +04:00
|
|
|
|
2012-06-21 01:41:21 +04:00
|
|
|
$ cd "$TESTTMP"
|
|
|
|
|
2013-01-30 22:40:07 +04:00
|
|
|
OSError "No such file or directory" / "The system cannot find the path
|
|
|
|
specified" should include filename even when it is empty
|
2013-01-07 05:00:29 +04:00
|
|
|
|
|
|
|
$ hg -R a archive ''
|
2013-01-30 22:40:07 +04:00
|
|
|
abort: *: '' (glob)
|
2013-01-07 05:00:29 +04:00
|
|
|
[255]
|
|
|
|
|
2012-06-21 01:41:21 +04:00
|
|
|
#if no-outer-repo
|
|
|
|
|
2010-09-02 19:13:23 +04:00
|
|
|
No repo:
|
|
|
|
|
|
|
|
$ hg cat
|
2011-04-20 23:28:40 +04:00
|
|
|
abort: no repository found in '$TESTTMP' (.hg not found)!
|
2010-09-17 02:51:32 +04:00
|
|
|
[255]
|
2010-09-02 19:13:23 +04:00
|
|
|
|
2012-06-21 01:41:21 +04:00
|
|
|
#endif
|
hgweb: do not import uuid immediately to avoid its side effect
With hgdemandimport disabled (chg's case), `import uuid` has an immediate
side effect calling `ctypes.util.find_library` trying to locate the
`libuuid` library. This happens at `import` time before `dispatch.run()`.
The call trace is like:
File "hg/hg", line 54, in <module>
from mercurial import (
File "hg/mercurial/dispatch.py", line 24, in <module>
from . import (
File "hg/mercurial/commands.py", line 23, in <module>
from . import (
File "hg/mercurial/help.py", line 33, in <module>
from .hgweb import (
File "hg/mercurial/hgweb/__init__.py", line 20, in <module>
from . import (
File "hg/mercurial/hgweb/hgweb_mod.py", line 14, in <module>
from .common import (
File "hg/mercurial/hgweb/common.py", line 15, in <module>
import uuid
File "/usr/lib64/python2.7/uuid.py", line 404, in <module>
lib = ctypes.CDLL(ctypes.util.find_library(libname))
The problem is, `ctypes.util.find_library` will execute
`sh -c '/sbin/ldconfig -p 2>/dev/null'` on Python <= 2.7.12. The output of
`sh` may pollute the terminal:
shell-init: error retrieving current directory: getcwd: cannot access
parent directories: No such file or directory
This patch moves `import uuid` so its side-effect can only happen after the
cwd check in `dispatch._getlocal`. Therefore the terminal won't be
polluted by importing `uuid`.
Differential Revision: https://phab.mercurial-scm.org/D1024
2017-10-12 07:24:32 +03:00
|
|
|
|
|
|
|
#if rmcwd
|
|
|
|
|
|
|
|
Current directory removed:
|
|
|
|
|
|
|
|
$ mkdir $TESTTMP/repo1
|
|
|
|
$ cd $TESTTMP/repo1
|
|
|
|
$ rm -rf $TESTTMP/repo1
|
2017-11-02 00:22:26 +03:00
|
|
|
|
|
|
|
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)
|
2017-12-03 03:33:34 +03:00
|
|
|
sh: 0: getcwd() failed: $ENOENT$
|
2017-11-02 00:22:26 +03:00
|
|
|
Since the exact behavior depends on the shell, only check it returns non-zero.
|
|
|
|
$ HGDEMANDIMPORT=disable hg version -q 2>/dev/null || false
|
|
|
|
[1]
|
hgweb: do not import uuid immediately to avoid its side effect
With hgdemandimport disabled (chg's case), `import uuid` has an immediate
side effect calling `ctypes.util.find_library` trying to locate the
`libuuid` library. This happens at `import` time before `dispatch.run()`.
The call trace is like:
File "hg/hg", line 54, in <module>
from mercurial import (
File "hg/mercurial/dispatch.py", line 24, in <module>
from . import (
File "hg/mercurial/commands.py", line 23, in <module>
from . import (
File "hg/mercurial/help.py", line 33, in <module>
from .hgweb import (
File "hg/mercurial/hgweb/__init__.py", line 20, in <module>
from . import (
File "hg/mercurial/hgweb/hgweb_mod.py", line 14, in <module>
from .common import (
File "hg/mercurial/hgweb/common.py", line 15, in <module>
import uuid
File "/usr/lib64/python2.7/uuid.py", line 404, in <module>
lib = ctypes.CDLL(ctypes.util.find_library(libname))
The problem is, `ctypes.util.find_library` will execute
`sh -c '/sbin/ldconfig -p 2>/dev/null'` on Python <= 2.7.12. The output of
`sh` may pollute the terminal:
shell-init: error retrieving current directory: getcwd: cannot access
parent directories: No such file or directory
This patch moves `import uuid` so its side-effect can only happen after the
cwd check in `dispatch._getlocal`. Therefore the terminal won't be
polluted by importing `uuid`.
Differential Revision: https://phab.mercurial-scm.org/D1024
2017-10-12 07:24:32 +03:00
|
|
|
|
|
|
|
#endif
|