annotate tests/test-dispatch.t @ 34643:f42dec9c976e

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
author Jun Wu <quark@fb.com>
date Wed, 11 Oct 2017 21:24:32 -0700
parents d65e246100ed
children 1ddc2547749f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
1 test command parsing and dispatch
4563
8044be585b91 dispatch: restore a dropped shlex import
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
2
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
3 $ hg init a
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
4 $ cd a
14115
1d5faa2c970f tests: move test-issue436 in test-dispatch where fancyopts is tested
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 13967
diff changeset
5
1d5faa2c970f tests: move test-issue436 in test-dispatch where fancyopts is tested
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 13967
diff changeset
6 Redundant options used to crash (issue436):
1d5faa2c970f tests: move test-issue436 in test-dispatch where fancyopts is tested
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 13967
diff changeset
7 $ hg -v log -v
1d5faa2c970f tests: move test-issue436 in test-dispatch where fancyopts is tested
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 13967
diff changeset
8 $ hg -v log -v x
1d5faa2c970f tests: move test-issue436 in test-dispatch where fancyopts is tested
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 13967
diff changeset
9
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
10 $ echo a > a
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
11 $ hg ci -Ama
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
12 adding a
4563
8044be585b91 dispatch: restore a dropped shlex import
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
13
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
14 Missing arg:
4621
6fc26982f203 dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents: 4563
diff changeset
15
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
16 $ hg cat
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
17 hg cat: invalid arguments
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
18 hg cat [OPTION]... FILE...
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
19
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
20 output the current or given revision of files
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
21
22117
c1d93edcf004 help: fold repeatable option message into option table header
Matt Mackall <mpm@selenic.com>
parents: 22111
diff changeset
22 options ([+] can be repeated):
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
23
15145
ff26712a0c50 help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents: 14115
diff changeset
24 -o --output FORMAT print output to file with formatted name
ff26712a0c50 help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents: 14115
diff changeset
25 -r --rev REV print the given revision
30152
d65e246100ed help: backout f3c4edfd35e1 (mark boolean flags with [no-] in help) for now
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30026
diff changeset
26 --decode apply any matching decode filter
15145
ff26712a0c50 help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents: 14115
diff changeset
27 -I --include PATTERN [+] include names matching the given patterns
ff26712a0c50 help: use RST to format option lists
Matt Mackall <mpm@selenic.com>
parents: 14115
diff changeset
28 -X --exclude PATTERN [+] exclude names matching the given patterns
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
29
29978
7109d5ddeb0c help: use single quotes in use warning
timeless <timeless@mozdev.org>
parents: 22117
diff changeset
30 (use 'hg cat -h' to show more help)
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12157
diff changeset
31 [255]
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
32
4563
8044be585b91 dispatch: restore a dropped shlex import
Brendan Cully <brendan@kublai.com>
parents:
diff changeset
33 [defaults]
4621
6fc26982f203 dispatch: fix handling of incorrect number of arguments
Matt Mackall <mpm@selenic.com>
parents: 4563
diff changeset
34
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
35 $ hg cat a
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
36 a
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
37 $ cat >> $HGRCPATH <<EOF
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
38 > [defaults]
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
39 > cat = -r null
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
40 > EOF
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
41 $ hg cat a
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
42 a: no such file in rev 000000000000
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12157
diff changeset
43 [1]
4654
e0e73ba37983 Fix dispatch error message when not in a repo
Brendan Cully <brendan@kublai.com>
parents: 4621
diff changeset
44
17014
50fbe9063ff2 tests: convert some 'hghave no-outer-repo' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 15145
diff changeset
45 $ cd "$TESTTMP"
50fbe9063ff2 tests: convert some 'hghave no-outer-repo' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 15145
diff changeset
46
18506
ef60083b5536 tests: fix for windows - slashes and no serve
Mads Kiilerich <madski@unity3d.com>
parents: 18227
diff changeset
47 OSError "No such file or directory" / "The system cannot find the path
ef60083b5536 tests: fix for windows - slashes and no serve
Mads Kiilerich <madski@unity3d.com>
parents: 18227
diff changeset
48 specified" should include filename even when it is empty
18227
720308f741cb dispatch: show empty filename in OSError aborts
Mads Kiilerich <mads@kiilerich.com>
parents: 18226
diff changeset
49
720308f741cb dispatch: show empty filename in OSError aborts
Mads Kiilerich <mads@kiilerich.com>
parents: 18226
diff changeset
50 $ hg -R a archive ''
18506
ef60083b5536 tests: fix for windows - slashes and no serve
Mads Kiilerich <madski@unity3d.com>
parents: 18227
diff changeset
51 abort: *: '' (glob)
18227
720308f741cb dispatch: show empty filename in OSError aborts
Mads Kiilerich <mads@kiilerich.com>
parents: 18226
diff changeset
52 [255]
720308f741cb dispatch: show empty filename in OSError aborts
Mads Kiilerich <mads@kiilerich.com>
parents: 18226
diff changeset
53
17014
50fbe9063ff2 tests: convert some 'hghave no-outer-repo' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 15145
diff changeset
54 #if no-outer-repo
50fbe9063ff2 tests: convert some 'hghave no-outer-repo' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 15145
diff changeset
55
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
56 No repo:
4659
7a7d4937272b Kill trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4654
diff changeset
57
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
58 $ hg cat
13967
f85c9b0fdb32 dispatch: improve repository not found message
Matt Mackall <mpm@selenic.com>
parents: 13950
diff changeset
59 abort: no repository found in '$TESTTMP' (.hg not found)!
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12157
diff changeset
60 [255]
12157
88250a460bf8 tests: unify test-dispatch
Adrian Buehlmann <adrian@cadifra.com>
parents: 12028
diff changeset
61
17014
50fbe9063ff2 tests: convert some 'hghave no-outer-repo' to #if
Mads Kiilerich <mads@kiilerich.com>
parents: 15145
diff changeset
62 #endif
34643
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
63
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
64 #if rmcwd
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
65
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
66 Current directory removed:
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
67
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
68 $ mkdir $TESTTMP/repo1
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
69 $ cd $TESTTMP/repo1
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
70 $ rm -rf $TESTTMP/repo1
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
71 $ HGDEMANDIMPORT=disable hg version -q
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
72 abort: error getting current working directory: * (glob)
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
73 [255]
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
74
f42dec9c976e hgweb: do not import uuid immediately to avoid its side effect
Jun Wu <quark@fb.com>
parents: 30152
diff changeset
75 #endif