Show More
@@ -1,141 +1,155 b'' | |||||
1 | #!/bin/sh |
|
1 | #!/bin/sh | |
2 | # Test basic extension support |
|
2 | # Test basic extension support | |
3 |
|
3 | |||
4 | "$TESTDIR/hghave" no-outer-repo || exit 80 |
|
4 | "$TESTDIR/hghave" no-outer-repo || exit 80 | |
5 |
|
5 | |||
6 | cat > foobar.py <<EOF |
|
6 | cat > foobar.py <<EOF | |
7 | import os |
|
7 | import os | |
8 | from mercurial import commands |
|
8 | from mercurial import commands | |
9 |
|
9 | |||
10 | def uisetup(ui): |
|
10 | def uisetup(ui): | |
11 | ui.write("uisetup called\\n") |
|
11 | ui.write("uisetup called\\n") | |
12 |
|
12 | |||
13 | def reposetup(ui, repo): |
|
13 | def reposetup(ui, repo): | |
14 | ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) |
|
14 | ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) | |
15 | ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!")) |
|
15 | ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!")) | |
16 |
|
16 | |||
17 | def foo(ui, *args, **kwargs): |
|
17 | def foo(ui, *args, **kwargs): | |
18 | ui.write("Foo\\n") |
|
18 | ui.write("Foo\\n") | |
19 |
|
19 | |||
20 | def bar(ui, *args, **kwargs): |
|
20 | def bar(ui, *args, **kwargs): | |
21 | ui.write("Bar\\n") |
|
21 | ui.write("Bar\\n") | |
22 |
|
22 | |||
23 | cmdtable = { |
|
23 | cmdtable = { | |
24 | "foo": (foo, [], "hg foo"), |
|
24 | "foo": (foo, [], "hg foo"), | |
25 | "bar": (bar, [], "hg bar"), |
|
25 | "bar": (bar, [], "hg bar"), | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | commands.norepo += ' bar' |
|
28 | commands.norepo += ' bar' | |
29 | EOF |
|
29 | EOF | |
30 | abspath=`pwd`/foobar.py |
|
30 | abspath=`pwd`/foobar.py | |
31 |
|
31 | |||
32 | mkdir barfoo |
|
32 | mkdir barfoo | |
33 | cp foobar.py barfoo/__init__.py |
|
33 | cp foobar.py barfoo/__init__.py | |
34 | barfoopath=`pwd`/barfoo |
|
34 | barfoopath=`pwd`/barfoo | |
35 |
|
35 | |||
36 | hg init a |
|
36 | hg init a | |
37 | cd a |
|
37 | cd a | |
38 | echo foo > file |
|
38 | echo foo > file | |
39 | hg add file |
|
39 | hg add file | |
40 | hg commit -m 'add file' |
|
40 | hg commit -m 'add file' | |
41 |
|
41 | |||
42 | echo '[extensions]' >> $HGRCPATH |
|
42 | echo '[extensions]' >> $HGRCPATH | |
43 | echo "foobar = $abspath" >> $HGRCPATH |
|
43 | echo "foobar = $abspath" >> $HGRCPATH | |
44 | hg foo |
|
44 | hg foo | |
45 |
|
45 | |||
46 | cd .. |
|
46 | cd .. | |
47 | hg clone a b |
|
47 | hg clone a b | |
48 |
|
48 | |||
49 | hg bar |
|
49 | hg bar | |
50 | echo 'foobar = !' >> $HGRCPATH |
|
50 | echo 'foobar = !' >> $HGRCPATH | |
51 |
|
51 | |||
52 | echo '% module/__init__.py-style' |
|
52 | echo '% module/__init__.py-style' | |
53 | echo "barfoo = $barfoopath" >> $HGRCPATH |
|
53 | echo "barfoo = $barfoopath" >> $HGRCPATH | |
54 | cd a |
|
54 | cd a | |
55 | hg foo |
|
55 | hg foo | |
56 | echo 'barfoo = !' >> $HGRCPATH |
|
56 | echo 'barfoo = !' >> $HGRCPATH | |
57 |
|
57 | |||
58 | # check that extensions are loaded in phases |
|
58 | # check that extensions are loaded in phases | |
59 | cat > foo.py <<EOF |
|
59 | cat > foo.py <<EOF | |
60 | import os |
|
60 | import os | |
61 | name = os.path.basename(__file__).rsplit('.', 1)[0] |
|
61 | name = os.path.basename(__file__).rsplit('.', 1)[0] | |
62 | print "1) %s imported" % name |
|
62 | print "1) %s imported" % name | |
63 | def uisetup(ui): |
|
63 | def uisetup(ui): | |
64 | print "2) %s uisetup" % name |
|
64 | print "2) %s uisetup" % name | |
65 | def extsetup(): |
|
65 | def extsetup(): | |
66 | print "3) %s extsetup" % name |
|
66 | print "3) %s extsetup" % name | |
67 | def reposetup(ui, repo): |
|
67 | def reposetup(ui, repo): | |
68 | print "4) %s reposetup" % name |
|
68 | print "4) %s reposetup" % name | |
69 | EOF |
|
69 | EOF | |
70 |
|
70 | |||
71 | cp foo.py bar.py |
|
71 | cp foo.py bar.py | |
72 | echo 'foo = foo.py' >> $HGRCPATH |
|
72 | echo 'foo = foo.py' >> $HGRCPATH | |
73 | echo 'bar = bar.py' >> $HGRCPATH |
|
73 | echo 'bar = bar.py' >> $HGRCPATH | |
74 |
|
74 | |||
75 | # command with no output, we just want to see the extensions loaded |
|
75 | # command with no output, we just want to see the extensions loaded | |
76 | hg paths |
|
76 | hg paths | |
77 |
|
77 | |||
|
78 | # check hgweb's load order | |||
|
79 | echo '% hgweb.cgi' | |||
|
80 | cat > hgweb.cgi <<EOF | |||
|
81 | #!/usr/bin/env python | |||
|
82 | from mercurial import demandimport; demandimport.enable() | |||
|
83 | from mercurial.hgweb import hgweb | |||
|
84 | from mercurial.hgweb import wsgicgi | |||
|
85 | ||||
|
86 | application = hgweb('.', 'test repo') | |||
|
87 | wsgicgi.launch(application) | |||
|
88 | EOF | |||
|
89 | SCRIPT_NAME='/' SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \ | |||
|
90 | | grep '^[[:digit:]]) [[:alnum:] ]*$' # ignores HTML output | |||
|
91 | ||||
78 | echo 'foo = !' >> $HGRCPATH |
|
92 | echo 'foo = !' >> $HGRCPATH | |
79 | echo 'bar = !' >> $HGRCPATH |
|
93 | echo 'bar = !' >> $HGRCPATH | |
80 |
|
94 | |||
81 | cd .. |
|
95 | cd .. | |
82 | cat > empty.py <<EOF |
|
96 | cat > empty.py <<EOF | |
83 | '''empty cmdtable |
|
97 | '''empty cmdtable | |
84 | ''' |
|
98 | ''' | |
85 | cmdtable = {} |
|
99 | cmdtable = {} | |
86 | EOF |
|
100 | EOF | |
87 | emptypath=`pwd`/empty.py |
|
101 | emptypath=`pwd`/empty.py | |
88 | echo "empty = $emptypath" >> $HGRCPATH |
|
102 | echo "empty = $emptypath" >> $HGRCPATH | |
89 | hg help empty |
|
103 | hg help empty | |
90 | echo 'empty = !' >> $HGRCPATH |
|
104 | echo 'empty = !' >> $HGRCPATH | |
91 |
|
105 | |||
92 | cat > debugextension.py <<EOF |
|
106 | cat > debugextension.py <<EOF | |
93 | '''only debugcommands |
|
107 | '''only debugcommands | |
94 | ''' |
|
108 | ''' | |
95 | def debugfoobar(ui, repo, *args, **opts): |
|
109 | def debugfoobar(ui, repo, *args, **opts): | |
96 | "yet another debug command" |
|
110 | "yet another debug command" | |
97 | pass |
|
111 | pass | |
98 |
|
112 | |||
99 | def foo(ui, repo, *args, **opts): |
|
113 | def foo(ui, repo, *args, **opts): | |
100 | """yet another foo command |
|
114 | """yet another foo command | |
101 |
|
115 | |||
102 | This command has been DEPRECATED since forever. |
|
116 | This command has been DEPRECATED since forever. | |
103 | """ |
|
117 | """ | |
104 | pass |
|
118 | pass | |
105 |
|
119 | |||
106 | cmdtable = { |
|
120 | cmdtable = { | |
107 | "debugfoobar": (debugfoobar, (), "hg debugfoobar"), |
|
121 | "debugfoobar": (debugfoobar, (), "hg debugfoobar"), | |
108 | "foo": (foo, (), "hg foo") |
|
122 | "foo": (foo, (), "hg foo") | |
109 | } |
|
123 | } | |
110 | EOF |
|
124 | EOF | |
111 | debugpath=`pwd`/debugextension.py |
|
125 | debugpath=`pwd`/debugextension.py | |
112 | echo "debugextension = $debugpath" >> $HGRCPATH |
|
126 | echo "debugextension = $debugpath" >> $HGRCPATH | |
113 | echo "% hg help" |
|
127 | echo "% hg help" | |
114 | hg help debugextension |
|
128 | hg help debugextension | |
115 | echo "% hg help --verbose" |
|
129 | echo "% hg help --verbose" | |
116 | hg --verbose help debugextension |
|
130 | hg --verbose help debugextension | |
117 | echo "% hg help --debug" |
|
131 | echo "% hg help --debug" | |
118 | hg --debug help debugextension |
|
132 | hg --debug help debugextension | |
119 | echo 'debugextension = !' >> $HGRCPATH |
|
133 | echo 'debugextension = !' >> $HGRCPATH | |
120 |
|
134 | |||
121 | echo % issue811 |
|
135 | echo % issue811 | |
122 | debugpath=`pwd`/debugissue811.py |
|
136 | debugpath=`pwd`/debugissue811.py | |
123 | cat > debugissue811.py <<EOF |
|
137 | cat > debugissue811.py <<EOF | |
124 | '''show all loaded extensions |
|
138 | '''show all loaded extensions | |
125 | ''' |
|
139 | ''' | |
126 | from mercurial import extensions, commands |
|
140 | from mercurial import extensions, commands | |
127 |
|
141 | |||
128 | def debugextensions(ui): |
|
142 | def debugextensions(ui): | |
129 | "yet another debug command" |
|
143 | "yet another debug command" | |
130 | ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()])) |
|
144 | ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()])) | |
131 |
|
145 | |||
132 | cmdtable = {"debugextensions": (debugextensions, (), "hg debugextensions")} |
|
146 | cmdtable = {"debugextensions": (debugextensions, (), "hg debugextensions")} | |
133 | commands.norepo += " debugextensions" |
|
147 | commands.norepo += " debugextensions" | |
134 | EOF |
|
148 | EOF | |
135 | echo "debugissue811 = $debugpath" >> $HGRCPATH |
|
149 | echo "debugissue811 = $debugpath" >> $HGRCPATH | |
136 | echo "mq=" >> $HGRCPATH |
|
150 | echo "mq=" >> $HGRCPATH | |
137 | echo "hgext.mq=" >> $HGRCPATH |
|
151 | echo "hgext.mq=" >> $HGRCPATH | |
138 | echo "hgext/mq=" >> $HGRCPATH |
|
152 | echo "hgext/mq=" >> $HGRCPATH | |
139 |
|
153 | |||
140 | echo % show extensions |
|
154 | echo % show extensions | |
141 | hg debugextensions |
|
155 | hg debugextensions |
@@ -1,95 +1,106 b'' | |||||
1 | uisetup called |
|
1 | uisetup called | |
2 | reposetup called for a |
|
2 | reposetup called for a | |
3 | ui == repo.ui |
|
3 | ui == repo.ui | |
4 | Foo |
|
4 | Foo | |
5 | uisetup called |
|
5 | uisetup called | |
6 | reposetup called for a |
|
6 | reposetup called for a | |
7 | ui == repo.ui |
|
7 | ui == repo.ui | |
8 | reposetup called for b |
|
8 | reposetup called for b | |
9 | ui == repo.ui |
|
9 | ui == repo.ui | |
10 | updating to branch default |
|
10 | updating to branch default | |
11 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
11 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
12 | uisetup called |
|
12 | uisetup called | |
13 | Bar |
|
13 | Bar | |
14 | % module/__init__.py-style |
|
14 | % module/__init__.py-style | |
15 | uisetup called |
|
15 | uisetup called | |
16 | reposetup called for a |
|
16 | reposetup called for a | |
17 | ui == repo.ui |
|
17 | ui == repo.ui | |
18 | Foo |
|
18 | Foo | |
19 | 1) foo imported |
|
19 | 1) foo imported | |
20 | 1) bar imported |
|
20 | 1) bar imported | |
21 | 2) foo uisetup |
|
21 | 2) foo uisetup | |
22 | 2) bar uisetup |
|
22 | 2) bar uisetup | |
23 | 3) foo extsetup |
|
23 | 3) foo extsetup | |
24 | 3) bar extsetup |
|
24 | 3) bar extsetup | |
25 | 4) foo reposetup |
|
25 | 4) foo reposetup | |
26 | 4) bar reposetup |
|
26 | 4) bar reposetup | |
|
27 | % hgweb.cgi | |||
|
28 | 1) foo imported | |||
|
29 | 1) bar imported | |||
|
30 | 2) foo uisetup | |||
|
31 | 2) bar uisetup | |||
|
32 | 3) foo extsetup | |||
|
33 | 3) bar extsetup | |||
|
34 | 4) foo reposetup | |||
|
35 | 4) bar reposetup | |||
|
36 | 4) foo reposetup | |||
|
37 | 4) bar reposetup | |||
27 | empty extension - empty cmdtable |
|
38 | empty extension - empty cmdtable | |
28 |
|
39 | |||
29 | no commands defined |
|
40 | no commands defined | |
30 | % hg help |
|
41 | % hg help | |
31 | debugextension extension - only debugcommands |
|
42 | debugextension extension - only debugcommands | |
32 |
|
43 | |||
33 | no commands defined |
|
44 | no commands defined | |
34 | % hg help --verbose |
|
45 | % hg help --verbose | |
35 | debugextension extension - only debugcommands |
|
46 | debugextension extension - only debugcommands | |
36 |
|
47 | |||
37 | list of commands: |
|
48 | list of commands: | |
38 |
|
49 | |||
39 | foo: |
|
50 | foo: | |
40 | yet another foo command |
|
51 | yet another foo command | |
41 |
|
52 | |||
42 | enabled extensions: |
|
53 | enabled extensions: | |
43 |
|
54 | |||
44 | debugextension only debugcommands |
|
55 | debugextension only debugcommands | |
45 |
|
56 | |||
46 | global options: |
|
57 | global options: | |
47 | -R --repository repository root directory or name of overlay bundle file |
|
58 | -R --repository repository root directory or name of overlay bundle file | |
48 | --cwd change working directory |
|
59 | --cwd change working directory | |
49 | -y --noninteractive do not prompt, assume 'yes' for any required answers |
|
60 | -y --noninteractive do not prompt, assume 'yes' for any required answers | |
50 | -q --quiet suppress output |
|
61 | -q --quiet suppress output | |
51 | -v --verbose enable additional output |
|
62 | -v --verbose enable additional output | |
52 | --config set/override config option |
|
63 | --config set/override config option | |
53 | --debug enable debugging output |
|
64 | --debug enable debugging output | |
54 | --debugger start debugger |
|
65 | --debugger start debugger | |
55 | --encoding set the charset encoding (default: ascii) |
|
66 | --encoding set the charset encoding (default: ascii) | |
56 | --encodingmode set the charset encoding mode (default: strict) |
|
67 | --encodingmode set the charset encoding mode (default: strict) | |
57 | --traceback print traceback on exception |
|
68 | --traceback print traceback on exception | |
58 | --time time how long the command takes |
|
69 | --time time how long the command takes | |
59 | --profile print command execution profile |
|
70 | --profile print command execution profile | |
60 | --version output version information and exit |
|
71 | --version output version information and exit | |
61 | -h --help display help and exit |
|
72 | -h --help display help and exit | |
62 | % hg help --debug |
|
73 | % hg help --debug | |
63 | debugextension extension - only debugcommands |
|
74 | debugextension extension - only debugcommands | |
64 |
|
75 | |||
65 | list of commands: |
|
76 | list of commands: | |
66 |
|
77 | |||
67 | debugfoobar: |
|
78 | debugfoobar: | |
68 | yet another debug command |
|
79 | yet another debug command | |
69 | foo: |
|
80 | foo: | |
70 | yet another foo command |
|
81 | yet another foo command | |
71 |
|
82 | |||
72 | enabled extensions: |
|
83 | enabled extensions: | |
73 |
|
84 | |||
74 | debugextension only debugcommands |
|
85 | debugextension only debugcommands | |
75 |
|
86 | |||
76 | global options: |
|
87 | global options: | |
77 | -R --repository repository root directory or name of overlay bundle file |
|
88 | -R --repository repository root directory or name of overlay bundle file | |
78 | --cwd change working directory |
|
89 | --cwd change working directory | |
79 | -y --noninteractive do not prompt, assume 'yes' for any required answers |
|
90 | -y --noninteractive do not prompt, assume 'yes' for any required answers | |
80 | -q --quiet suppress output |
|
91 | -q --quiet suppress output | |
81 | -v --verbose enable additional output |
|
92 | -v --verbose enable additional output | |
82 | --config set/override config option |
|
93 | --config set/override config option | |
83 | --debug enable debugging output |
|
94 | --debug enable debugging output | |
84 | --debugger start debugger |
|
95 | --debugger start debugger | |
85 | --encoding set the charset encoding (default: ascii) |
|
96 | --encoding set the charset encoding (default: ascii) | |
86 | --encodingmode set the charset encoding mode (default: strict) |
|
97 | --encodingmode set the charset encoding mode (default: strict) | |
87 | --traceback print traceback on exception |
|
98 | --traceback print traceback on exception | |
88 | --time time how long the command takes |
|
99 | --time time how long the command takes | |
89 | --profile print command execution profile |
|
100 | --profile print command execution profile | |
90 | --version output version information and exit |
|
101 | --version output version information and exit | |
91 | -h --help display help and exit |
|
102 | -h --help display help and exit | |
92 | % issue811 |
|
103 | % issue811 | |
93 | % show extensions |
|
104 | % show extensions | |
94 | debugissue811 |
|
105 | debugissue811 | |
95 | mq |
|
106 | mq |
General Comments 0
You need to be logged in to leave comments.
Login now