Show More
@@ -1,165 +1,166 b'' | |||
|
1 | #require no-chg | |
|
1 | 2 | $ filterlog () { |
|
2 | 3 | > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' |
|
3 | 4 | > } |
|
4 | 5 | |
|
5 | 6 | ensure that failing ui.atexit handlers report sensibly |
|
6 | 7 | |
|
7 | 8 | $ cat > $TESTTMP/bailatexit.py <<EOF |
|
8 | 9 | > from mercurial import util |
|
9 | 10 | > def bail(): |
|
10 | 11 | > raise RuntimeError('ui.atexit handler exception') |
|
11 | 12 | > |
|
12 | 13 | > def extsetup(ui): |
|
13 | 14 | > ui.atexit(bail) |
|
14 | 15 | > EOF |
|
15 | 16 | $ hg -q --config extensions.bailatexit=$TESTTMP/bailatexit.py \ |
|
16 | 17 | > help help |
|
17 | 18 | hg help [-eck] [-s PLATFORM] [TOPIC] |
|
18 | 19 | |
|
19 | 20 | show help for a given topic or a help overview |
|
20 | 21 | error in exit handlers: |
|
21 | 22 | Traceback (most recent call last): |
|
22 | 23 | File "*/mercurial/dispatch.py", line *, in _runexithandlers (glob) |
|
23 | 24 | func(*args, **kwargs) |
|
24 | 25 | File "$TESTTMP/bailatexit.py", line *, in bail (glob) |
|
25 | 26 | raise RuntimeError('ui.atexit handler exception') |
|
26 | 27 | RuntimeError: ui.atexit handler exception |
|
27 | 28 | [255] |
|
28 | 29 | |
|
29 | 30 | $ rm $TESTTMP/bailatexit.py |
|
30 | 31 | |
|
31 | 32 | another bad extension |
|
32 | 33 | |
|
33 | 34 | $ echo 'raise Exception("bit bucket overflow")' > badext.py |
|
34 | 35 | $ abspathexc=`pwd`/badext.py |
|
35 | 36 | |
|
36 | 37 | $ cat >baddocext.py <<EOF |
|
37 | 38 | > """ |
|
38 | 39 | > baddocext is bad |
|
39 | 40 | > """ |
|
40 | 41 | > EOF |
|
41 | 42 | $ abspathdoc=`pwd`/baddocext.py |
|
42 | 43 | |
|
43 | 44 | $ cat <<EOF >> $HGRCPATH |
|
44 | 45 | > [extensions] |
|
45 | 46 | > gpg = |
|
46 | 47 | > hgext.gpg = |
|
47 | 48 | > badext = $abspathexc |
|
48 | 49 | > baddocext = $abspathdoc |
|
49 | 50 | > badext2 = |
|
50 | 51 | > EOF |
|
51 | 52 | |
|
52 | 53 | $ hg -q help help 2>&1 |grep extension |
|
53 | 54 | *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow |
|
54 | 55 | *** failed to import extension badext2: No module named *badext2* (glob) |
|
55 | 56 | |
|
56 | 57 | show traceback |
|
57 | 58 | |
|
58 | 59 | $ hg -q help help --traceback 2>&1 | egrep ' extension|^Exception|Traceback|ImportError|ModuleNotFound' |
|
59 | 60 | *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow |
|
60 | 61 | Traceback (most recent call last): |
|
61 | 62 | Exception: bit bucket overflow |
|
62 | 63 | *** failed to import extension badext2: No module named *badext2* (glob) |
|
63 | 64 | Traceback (most recent call last): |
|
64 | 65 | ImportError: No module named badext2 (no-py3 !) |
|
65 | 66 | ImportError: No module named 'hgext.badext2' (py3 no-py36 !) |
|
66 | 67 | ModuleNotFoundError: No module named 'hgext.badext2' (py36 !) |
|
67 | 68 | Traceback (most recent call last): (py3 !) |
|
68 | 69 | ImportError: No module named 'hgext3rd.badext2' (py3 no-py36 !) |
|
69 | 70 | ModuleNotFoundError: No module named 'hgext3rd.badext2' (py36 !) |
|
70 | 71 | Traceback (most recent call last): (py3 !) |
|
71 | 72 | ImportError: No module named 'badext2' (py3 no-py36 !) |
|
72 | 73 | ModuleNotFoundError: No module named 'badext2' (py36 !) |
|
73 | 74 | |
|
74 | 75 | names of extensions failed to load can be accessed via extensions.notloaded() |
|
75 | 76 | |
|
76 | 77 | $ cat <<EOF > showbadexts.py |
|
77 | 78 | > from mercurial import commands, extensions, registrar |
|
78 | 79 | > cmdtable = {} |
|
79 | 80 | > command = registrar.command(cmdtable) |
|
80 | 81 | > @command(b'showbadexts', norepo=True) |
|
81 | 82 | > def showbadexts(ui, *pats, **opts): |
|
82 | 83 | > ui.write(b'BADEXTS: %s\n' % b' '.join(sorted(extensions.notloaded()))) |
|
83 | 84 | > EOF |
|
84 | 85 | $ hg --config extensions.badexts=showbadexts.py showbadexts 2>&1 | grep '^BADEXTS' |
|
85 | 86 | BADEXTS: badext badext2 |
|
86 | 87 | |
|
87 | 88 | #if no-extraextensions |
|
88 | 89 | show traceback for ImportError of hgext.name if devel.debug.extensions is set |
|
89 | 90 | |
|
90 | 91 | $ (hg help help --traceback --debug --config devel.debug.extensions=yes 2>&1) \ |
|
91 | 92 | > | grep -v '^ ' \ |
|
92 | 93 | > | filterlog \ |
|
93 | 94 | > | egrep 'extension..[^p]|^Exception|Traceback|ImportError|^YYYY|not import|ModuleNotFound' |
|
94 | 95 | YYYY/MM/DD HH:MM:SS (PID)> loading extensions |
|
95 | 96 | YYYY/MM/DD HH:MM:SS (PID)> - processing 5 entries |
|
96 | 97 | YYYY/MM/DD HH:MM:SS (PID)> - loading extension: gpg |
|
97 | 98 | YYYY/MM/DD HH:MM:SS (PID)> > gpg extension loaded in * (glob) |
|
98 | 99 | YYYY/MM/DD HH:MM:SS (PID)> - validating extension tables: gpg |
|
99 | 100 | YYYY/MM/DD HH:MM:SS (PID)> - invoking registered callbacks: gpg |
|
100 | 101 | YYYY/MM/DD HH:MM:SS (PID)> > callbacks completed in * (glob) |
|
101 | 102 | YYYY/MM/DD HH:MM:SS (PID)> - loading extension: badext |
|
102 | 103 | *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow |
|
103 | 104 | Traceback (most recent call last): |
|
104 | 105 | Exception: bit bucket overflow |
|
105 | 106 | YYYY/MM/DD HH:MM:SS (PID)> - loading extension: baddocext |
|
106 | 107 | YYYY/MM/DD HH:MM:SS (PID)> > baddocext extension loaded in * (glob) |
|
107 | 108 | YYYY/MM/DD HH:MM:SS (PID)> - validating extension tables: baddocext |
|
108 | 109 | YYYY/MM/DD HH:MM:SS (PID)> - invoking registered callbacks: baddocext |
|
109 | 110 | YYYY/MM/DD HH:MM:SS (PID)> > callbacks completed in * (glob) |
|
110 | 111 | YYYY/MM/DD HH:MM:SS (PID)> - loading extension: badext2 |
|
111 | 112 | YYYY/MM/DD HH:MM:SS (PID)> - could not import hgext.badext2 (No module named *badext2*): trying hgext3rd.badext2 (glob) |
|
112 | 113 | Traceback (most recent call last): |
|
113 | 114 | ImportError: No module named badext2 (no-py3 !) |
|
114 | 115 | ImportError: No module named 'hgext.badext2' (py3 no-py36 !) |
|
115 | 116 | ModuleNotFoundError: No module named 'hgext.badext2' (py36 !) |
|
116 | 117 | YYYY/MM/DD HH:MM:SS (PID)> - could not import hgext3rd.badext2 (No module named *badext2*): trying badext2 (glob) |
|
117 | 118 | Traceback (most recent call last): |
|
118 | 119 | ImportError: No module named badext2 (no-py3 !) |
|
119 | 120 | ImportError: No module named 'hgext.badext2' (py3 no-py36 !) |
|
120 | 121 | ModuleNotFoundError: No module named 'hgext.badext2' (py36 !) |
|
121 | 122 | Traceback (most recent call last): (py3 !) |
|
122 | 123 | ImportError: No module named 'hgext3rd.badext2' (py3 no-py36 !) |
|
123 | 124 | ModuleNotFoundError: No module named 'hgext3rd.badext2' (py36 !) |
|
124 | 125 | *** failed to import extension badext2: No module named *badext2* (glob) |
|
125 | 126 | Traceback (most recent call last): |
|
126 | 127 | ImportError: No module named 'hgext.badext2' (py3 no-py36 !) |
|
127 | 128 | ModuleNotFoundError: No module named 'hgext.badext2' (py36 !) |
|
128 | 129 | Traceback (most recent call last): (py3 !) |
|
129 | 130 | ImportError: No module named 'hgext3rd.badext2' (py3 no-py36 !) |
|
130 | 131 | ModuleNotFoundError: No module named 'hgext3rd.badext2' (py36 !) |
|
131 | 132 | Traceback (most recent call last): (py3 !) |
|
132 | 133 | ModuleNotFoundError: No module named 'badext2' (py36 !) |
|
133 | 134 | ImportError: No module named 'badext2' (py3 no-py36 !) |
|
134 | 135 | ImportError: No module named badext2 (no-py3 !) |
|
135 | 136 | YYYY/MM/DD HH:MM:SS (PID)> > loaded 2 extensions, total time * (glob) |
|
136 | 137 | YYYY/MM/DD HH:MM:SS (PID)> - loading configtable attributes |
|
137 | 138 | YYYY/MM/DD HH:MM:SS (PID)> - executing uisetup hooks |
|
138 | 139 | YYYY/MM/DD HH:MM:SS (PID)> - running uisetup for gpg |
|
139 | 140 | YYYY/MM/DD HH:MM:SS (PID)> > uisetup for gpg took * (glob) |
|
140 | 141 | YYYY/MM/DD HH:MM:SS (PID)> - running uisetup for baddocext |
|
141 | 142 | YYYY/MM/DD HH:MM:SS (PID)> > uisetup for baddocext took * (glob) |
|
142 | 143 | YYYY/MM/DD HH:MM:SS (PID)> > all uisetup took * (glob) |
|
143 | 144 | YYYY/MM/DD HH:MM:SS (PID)> - executing extsetup hooks |
|
144 | 145 | YYYY/MM/DD HH:MM:SS (PID)> - running extsetup for gpg |
|
145 | 146 | YYYY/MM/DD HH:MM:SS (PID)> > extsetup for gpg took * (glob) |
|
146 | 147 | YYYY/MM/DD HH:MM:SS (PID)> - running extsetup for baddocext |
|
147 | 148 | YYYY/MM/DD HH:MM:SS (PID)> > extsetup for baddocext took * (glob) |
|
148 | 149 | YYYY/MM/DD HH:MM:SS (PID)> > all extsetup took * (glob) |
|
149 | 150 | YYYY/MM/DD HH:MM:SS (PID)> - executing remaining aftercallbacks |
|
150 | 151 | YYYY/MM/DD HH:MM:SS (PID)> > remaining aftercallbacks completed in * (glob) |
|
151 | 152 | YYYY/MM/DD HH:MM:SS (PID)> - loading extension registration objects |
|
152 | 153 | YYYY/MM/DD HH:MM:SS (PID)> > extension registration object loading took * (glob) |
|
153 | 154 | YYYY/MM/DD HH:MM:SS (PID)> > extension baddocext take a total of * to load (glob) |
|
154 | 155 | YYYY/MM/DD HH:MM:SS (PID)> > extension gpg take a total of * to load (glob) |
|
155 | 156 | YYYY/MM/DD HH:MM:SS (PID)> extension loading complete |
|
156 | 157 | #endif |
|
157 | 158 | |
|
158 | 159 | confirm that there's no crash when an extension's documentation is bad |
|
159 | 160 | |
|
160 | 161 | $ hg help --keyword baddocext |
|
161 | 162 | *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow |
|
162 | 163 | *** failed to import extension badext2: No module named *badext2* (glob) |
|
163 | 164 | Topics: |
|
164 | 165 | |
|
165 | 166 | extensions Using Additional Features |
@@ -1,100 +1,102 b'' | |||
|
1 | #require no-chg | |
|
2 | ||
|
1 | 3 | Test basic extension support |
|
2 | 4 | |
|
3 | 5 | $ cat > foobar.py <<EOF |
|
4 | 6 | > import os |
|
5 | 7 | > from mercurial import commands, registrar |
|
6 | 8 | > cmdtable = {} |
|
7 | 9 | > command = registrar.command(cmdtable) |
|
8 | 10 | > configtable = {} |
|
9 | 11 | > configitem = registrar.configitem(configtable) |
|
10 | 12 | > configitem(b'tests', b'foo', default=b"Foo") |
|
11 | 13 | > def uisetup(ui): |
|
12 | 14 | > ui.debug(b"uisetup called [debug]\\n") |
|
13 | 15 | > ui.write(b"uisetup called\\n") |
|
14 | 16 | > ui.status(b"uisetup called [status]\\n") |
|
15 | 17 | > ui.flush() |
|
16 | 18 | > def reposetup(ui, repo): |
|
17 | 19 | > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root)) |
|
18 | 20 | > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!")) |
|
19 | 21 | > ui.flush() |
|
20 | 22 | > @command(b'foo', [], b'hg foo') |
|
21 | 23 | > def foo(ui, *args, **kwargs): |
|
22 | 24 | > foo = ui.config(b'tests', b'foo') |
|
23 | 25 | > ui.write(foo) |
|
24 | 26 | > ui.write(b"\\n") |
|
25 | 27 | > @command(b'bar', [], b'hg bar', norepo=True) |
|
26 | 28 | > def bar(ui, *args, **kwargs): |
|
27 | 29 | > ui.write(b"Bar\\n") |
|
28 | 30 | > EOF |
|
29 | 31 | $ abspath=`pwd`/foobar.py |
|
30 | 32 | |
|
31 | 33 | $ mkdir barfoo |
|
32 | 34 | $ cp foobar.py barfoo/__init__.py |
|
33 | 35 | $ barfoopath=`pwd`/barfoo |
|
34 | 36 | |
|
35 | 37 | $ hg init a |
|
36 | 38 | $ cd a |
|
37 | 39 | $ echo foo > file |
|
38 | 40 | $ hg add file |
|
39 | 41 | $ hg commit -m 'add file' |
|
40 | 42 | |
|
41 | 43 | $ echo '[extensions]' >> $HGRCPATH |
|
42 | 44 | $ echo "foobar = $abspath" >> $HGRCPATH |
|
43 | 45 | |
|
44 | 46 | $ filterlog () { |
|
45 | 47 | > sed -e 's!^[0-9/]* [0-9:]* ([0-9]*)>!YYYY/MM/DD HH:MM:SS (PID)>!' |
|
46 | 48 | > } |
|
47 | 49 | |
|
48 | 50 | Test extension setup timings |
|
49 | 51 | |
|
50 | 52 | $ hg foo --traceback --config devel.debug.extensions=yes --debug 2>&1 | filterlog |
|
51 | 53 | YYYY/MM/DD HH:MM:SS (PID)> loading extensions |
|
52 | 54 | YYYY/MM/DD HH:MM:SS (PID)> - processing 1 entries |
|
53 | 55 | YYYY/MM/DD HH:MM:SS (PID)> - loading extension: foobar |
|
54 | 56 | YYYY/MM/DD HH:MM:SS (PID)> > foobar extension loaded in * (glob) |
|
55 | 57 | YYYY/MM/DD HH:MM:SS (PID)> - validating extension tables: foobar |
|
56 | 58 | YYYY/MM/DD HH:MM:SS (PID)> - invoking registered callbacks: foobar |
|
57 | 59 | YYYY/MM/DD HH:MM:SS (PID)> > callbacks completed in * (glob) |
|
58 | 60 | YYYY/MM/DD HH:MM:SS (PID)> > loaded 1 extensions, total time * (glob) |
|
59 | 61 | YYYY/MM/DD HH:MM:SS (PID)> - loading configtable attributes |
|
60 | 62 | YYYY/MM/DD HH:MM:SS (PID)> - executing uisetup hooks |
|
61 | 63 | YYYY/MM/DD HH:MM:SS (PID)> - running uisetup for foobar |
|
62 | 64 | uisetup called [debug] |
|
63 | 65 | uisetup called |
|
64 | 66 | uisetup called [status] |
|
65 | 67 | YYYY/MM/DD HH:MM:SS (PID)> > uisetup for foobar took * (glob) |
|
66 | 68 | YYYY/MM/DD HH:MM:SS (PID)> > all uisetup took * (glob) |
|
67 | 69 | YYYY/MM/DD HH:MM:SS (PID)> - executing extsetup hooks |
|
68 | 70 | YYYY/MM/DD HH:MM:SS (PID)> - running extsetup for foobar |
|
69 | 71 | YYYY/MM/DD HH:MM:SS (PID)> > extsetup for foobar took * (glob) |
|
70 | 72 | YYYY/MM/DD HH:MM:SS (PID)> > all extsetup took * (glob) |
|
71 | 73 | YYYY/MM/DD HH:MM:SS (PID)> - executing remaining aftercallbacks |
|
72 | 74 | YYYY/MM/DD HH:MM:SS (PID)> > remaining aftercallbacks completed in * (glob) |
|
73 | 75 | YYYY/MM/DD HH:MM:SS (PID)> - loading extension registration objects |
|
74 | 76 | YYYY/MM/DD HH:MM:SS (PID)> > extension registration object loading took * (glob) |
|
75 | 77 | YYYY/MM/DD HH:MM:SS (PID)> > extension foobar take a total of * to load (glob) |
|
76 | 78 | YYYY/MM/DD HH:MM:SS (PID)> extension loading complete |
|
77 | 79 | YYYY/MM/DD HH:MM:SS (PID)> loading additional extensions |
|
78 | 80 | YYYY/MM/DD HH:MM:SS (PID)> - processing 1 entries |
|
79 | 81 | YYYY/MM/DD HH:MM:SS (PID)> > loaded 0 extensions, total time * (glob) |
|
80 | 82 | YYYY/MM/DD HH:MM:SS (PID)> - loading configtable attributes |
|
81 | 83 | YYYY/MM/DD HH:MM:SS (PID)> - executing uisetup hooks |
|
82 | 84 | YYYY/MM/DD HH:MM:SS (PID)> > all uisetup took * (glob) |
|
83 | 85 | YYYY/MM/DD HH:MM:SS (PID)> - executing extsetup hooks |
|
84 | 86 | YYYY/MM/DD HH:MM:SS (PID)> > all extsetup took * (glob) |
|
85 | 87 | YYYY/MM/DD HH:MM:SS (PID)> - executing remaining aftercallbacks |
|
86 | 88 | YYYY/MM/DD HH:MM:SS (PID)> > remaining aftercallbacks completed in * (glob) |
|
87 | 89 | YYYY/MM/DD HH:MM:SS (PID)> - loading extension registration objects |
|
88 | 90 | YYYY/MM/DD HH:MM:SS (PID)> > extension registration object loading took * (glob) |
|
89 | 91 | YYYY/MM/DD HH:MM:SS (PID)> extension loading complete |
|
90 | 92 | YYYY/MM/DD HH:MM:SS (PID)> - executing reposetup hooks |
|
91 | 93 | YYYY/MM/DD HH:MM:SS (PID)> - running reposetup for foobar |
|
92 | 94 | reposetup called for a |
|
93 | 95 | ui == repo.ui |
|
94 | 96 | YYYY/MM/DD HH:MM:SS (PID)> > reposetup for foobar took * (glob) |
|
95 | 97 | YYYY/MM/DD HH:MM:SS (PID)> > all reposetup took * (glob) |
|
96 | 98 | Foo |
|
97 | 99 | |
|
98 | 100 | $ cd .. |
|
99 | 101 | |
|
100 | 102 | $ echo 'foobar = !' >> $HGRCPATH |
General Comments 0
You need to be logged in to leave comments.
Login now