Show More
@@ -0,0 +1,42 | |||||
|
1 | #!/bin/sh | |||
|
2 | # Test basic extension support | |||
|
3 | ||||
|
4 | cat > foobar.py <<EOF | |||
|
5 | import os | |||
|
6 | from mercurial import commands | |||
|
7 | ||||
|
8 | def uisetup(ui): | |||
|
9 | ui.write("uisetup called\\n") | |||
|
10 | ||||
|
11 | def reposetup(ui, repo): | |||
|
12 | ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) | |||
|
13 | ||||
|
14 | def foo(ui, *args, **kwargs): | |||
|
15 | ui.write("Foo\\n") | |||
|
16 | ||||
|
17 | def bar(ui, *args, **kwargs): | |||
|
18 | ui.write("Bar\\n") | |||
|
19 | ||||
|
20 | cmdtable = { | |||
|
21 | "foo": (foo, [], "hg foo"), | |||
|
22 | "bar": (bar, [], "hg bar"), | |||
|
23 | } | |||
|
24 | ||||
|
25 | commands.norepo += ' bar' | |||
|
26 | EOF | |||
|
27 | abspath=`pwd`/foobar.py | |||
|
28 | ||||
|
29 | hg init a | |||
|
30 | cd a | |||
|
31 | echo foo > file | |||
|
32 | hg add file | |||
|
33 | hg commit -m 'add file' | |||
|
34 | ||||
|
35 | echo '[extensions]' >> $HGRCPATH | |||
|
36 | echo "foobar = $abspath" >> $HGRCPATH | |||
|
37 | hg foo | |||
|
38 | ||||
|
39 | cd .. | |||
|
40 | hg clone a b | |||
|
41 | ||||
|
42 | hg bar |
@@ -0,0 +1,9 | |||||
|
1 | uisetup called | |||
|
2 | reposetup called for a | |||
|
3 | Foo | |||
|
4 | uisetup called | |||
|
5 | reposetup called for a | |||
|
6 | reposetup called for b | |||
|
7 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
8 | uisetup called | |||
|
9 | Bar |
@@ -3106,6 +3106,9 def load_extensions(ui): | |||||
3106 | uisetup = getattr(mod, 'uisetup', None) |
|
3106 | uisetup = getattr(mod, 'uisetup', None) | |
3107 | if uisetup: |
|
3107 | if uisetup: | |
3108 | uisetup(ui) |
|
3108 | uisetup(ui) | |
|
3109 | reposetup = getattr(mod, 'reposetup', None) | |||
|
3110 | if reposetup: | |||
|
3111 | hg.repo_setup_hooks.append(reposetup) | |||
3109 | cmdtable = getattr(mod, 'cmdtable', {}) |
|
3112 | cmdtable = getattr(mod, 'cmdtable', {}) | |
3110 | for t in cmdtable: |
|
3113 | for t in cmdtable: | |
3111 | if t in table: |
|
3114 | if t in table: | |
@@ -3188,11 +3191,6 def dispatch(args): | |||||
3188 | if not repo: |
|
3191 | if not repo: | |
3189 | repo = hg.repository(u, path=path) |
|
3192 | repo = hg.repository(u, path=path) | |
3190 | u = repo.ui |
|
3193 | u = repo.ui | |
3191 | for name in external.itervalues(): |
|
|||
3192 | mod = sys.modules[name] |
|
|||
3193 | if hasattr(mod, 'reposetup'): |
|
|||
3194 | mod.reposetup(u, repo) |
|
|||
3195 | hg.repo_setup_hooks.append(mod.reposetup) |
|
|||
3196 | except hg.RepoError: |
|
3194 | except hg.RepoError: | |
3197 | if cmd not in optionalrepo.split(): |
|
3195 | if cmd not in optionalrepo.split(): | |
3198 | raise |
|
3196 | raise |
General Comments 0
You need to be logged in to leave comments.
Login now