Show More
@@ -0,0 +1,113 b'' | |||||
|
1 | Test the extensions.afterloaded() function | |||
|
2 | ||||
|
3 | $ cat > foo.py <<EOF | |||
|
4 | > from mercurial import extensions | |||
|
5 | > def uisetup(ui): | |||
|
6 | > ui.write("foo.uisetup\\n") | |||
|
7 | > ui.flush() | |||
|
8 | > def bar_loaded(loaded): | |||
|
9 | > ui.write("foo: bar loaded: %r\\n" % (loaded,)) | |||
|
10 | > ui.flush() | |||
|
11 | > extensions.afterloaded('bar', bar_loaded) | |||
|
12 | > EOF | |||
|
13 | $ cat > bar.py <<EOF | |||
|
14 | > def uisetup(ui): | |||
|
15 | > ui.write("bar.uisetup\\n") | |||
|
16 | > ui.flush() | |||
|
17 | > EOF | |||
|
18 | $ basepath=`pwd` | |||
|
19 | ||||
|
20 | $ hg init basic | |||
|
21 | $ cd basic | |||
|
22 | $ echo foo > file | |||
|
23 | $ hg add file | |||
|
24 | $ hg commit -m 'add file' | |||
|
25 | ||||
|
26 | $ echo '[extensions]' >> .hg/hgrc | |||
|
27 | $ echo "foo = $basepath/foo.py" >> .hg/hgrc | |||
|
28 | $ echo "bar = $basepath/bar.py" >> .hg/hgrc | |||
|
29 | $ hg log -r. -T'{rev}\n' | |||
|
30 | foo.uisetup | |||
|
31 | foo: bar loaded: True | |||
|
32 | bar.uisetup | |||
|
33 | 0 | |||
|
34 | ||||
|
35 | Test afterloaded with the opposite extension load order | |||
|
36 | ||||
|
37 | $ cd .. | |||
|
38 | $ hg init basic_reverse | |||
|
39 | $ cd basic_reverse | |||
|
40 | $ echo foo > file | |||
|
41 | $ hg add file | |||
|
42 | $ hg commit -m 'add file' | |||
|
43 | ||||
|
44 | $ echo '[extensions]' >> .hg/hgrc | |||
|
45 | $ echo "bar = $basepath/bar.py" >> .hg/hgrc | |||
|
46 | $ echo "foo = $basepath/foo.py" >> .hg/hgrc | |||
|
47 | $ hg log -r. -T'{rev}\n' | |||
|
48 | bar.uisetup | |||
|
49 | foo.uisetup | |||
|
50 | foo: bar loaded: True | |||
|
51 | 0 | |||
|
52 | ||||
|
53 | Test the extensions.afterloaded() function when the requested extension is not | |||
|
54 | loaded | |||
|
55 | ||||
|
56 | $ cd .. | |||
|
57 | $ hg init notloaded | |||
|
58 | $ cd notloaded | |||
|
59 | $ echo foo > file | |||
|
60 | $ hg add file | |||
|
61 | $ hg commit -m 'add file' | |||
|
62 | ||||
|
63 | $ echo '[extensions]' >> .hg/hgrc | |||
|
64 | $ echo "foo = $basepath/foo.py" >> .hg/hgrc | |||
|
65 | $ hg log -r. -T'{rev}\n' | |||
|
66 | foo.uisetup | |||
|
67 | foo: bar loaded: False | |||
|
68 | 0 | |||
|
69 | ||||
|
70 | Test the extensions.afterloaded() function when the requested extension is not | |||
|
71 | configured but fails the minimum version check | |||
|
72 | ||||
|
73 | $ cd .. | |||
|
74 | $ cat > minvers.py <<EOF | |||
|
75 | > minimumhgversion = '9999.9999' | |||
|
76 | > def uisetup(ui): | |||
|
77 | > ui.write("minvers.uisetup\\n") | |||
|
78 | > ui.flush() | |||
|
79 | > EOF | |||
|
80 | $ hg init minversion | |||
|
81 | $ cd minversion | |||
|
82 | $ echo foo > file | |||
|
83 | $ hg add file | |||
|
84 | $ hg commit -m 'add file' | |||
|
85 | ||||
|
86 | $ echo '[extensions]' >> .hg/hgrc | |||
|
87 | $ echo "foo = $basepath/foo.py" >> .hg/hgrc | |||
|
88 | $ echo "bar = $basepath/minvers.py" >> .hg/hgrc | |||
|
89 | $ hg log -r. -T'{rev}\n' | |||
|
90 | (third party extension bar requires version 9999.9999 or newer of Mercurial; disabling) | |||
|
91 | foo.uisetup | |||
|
92 | foo: bar loaded: False | |||
|
93 | 0 | |||
|
94 | ||||
|
95 | Test the extensions.afterloaded() function when the requested extension is not | |||
|
96 | configured but fails the minimum version check, using the opposite load order | |||
|
97 | for the two extensions. | |||
|
98 | ||||
|
99 | $ cd .. | |||
|
100 | $ hg init minversion_reverse | |||
|
101 | $ cd minversion_reverse | |||
|
102 | $ echo foo > file | |||
|
103 | $ hg add file | |||
|
104 | $ hg commit -m 'add file' | |||
|
105 | ||||
|
106 | $ echo '[extensions]' >> .hg/hgrc | |||
|
107 | $ echo "bar = $basepath/minvers.py" >> .hg/hgrc | |||
|
108 | $ echo "foo = $basepath/foo.py" >> .hg/hgrc | |||
|
109 | $ hg log -r. -T'{rev}\n' | |||
|
110 | (third party extension bar requires version 9999.9999 or newer of Mercurial; disabling) | |||
|
111 | foo.uisetup | |||
|
112 | foo: bar loaded: False | |||
|
113 | 0 |
@@ -257,7 +257,9 b' def afterloaded(extension, callback):' | |||||
257 | ''' |
|
257 | ''' | |
258 |
|
258 | |||
259 | if extension in _extensions: |
|
259 | if extension in _extensions: | |
260 | callback(loaded=True) |
|
260 | # Report loaded as False if the extension is disabled | |
|
261 | loaded = (_extensions[extension] is not None) | |||
|
262 | callback(loaded=loaded) | |||
261 | else: |
|
263 | else: | |
262 | _aftercallbacks.setdefault(extension, []).append(callback) |
|
264 | _aftercallbacks.setdefault(extension, []).append(callback) | |
263 |
|
265 |
General Comments 0
You need to be logged in to leave comments.
Login now