##// END OF EJS Templates
extensions: load modules in module/__init__.py form....
Brendan Cully -
r4569:622d8ed7 default
parent child Browse files
Show More
@@ -5,7 +5,8 b''
5 # This software may be used and distributed according to the terms
5 # This software may be used and distributed according to the terms
6 # of the GNU General Public License, incorporated herein by reference.
6 # of the GNU General Public License, incorporated herein by reference.
7
7
8 import imp, commands, hg, util, sys
8 import imp, os
9 import commands, hg, util, sys
9 from i18n import _
10 from i18n import _
10
11
11 _extensions = {}
12 _extensions = {}
@@ -28,7 +29,12 b' def load(ui, name, path):'
28 # choose an unique name so that it doesn't
29 # choose an unique name so that it doesn't
29 # conflicts with other modules
30 # conflicts with other modules
30 module_name = "hgext_%s" % name.replace('.', '_')
31 module_name = "hgext_%s" % name.replace('.', '_')
31 mod = imp.load_source(module_name, path)
32 if os.path.isdir(path):
33 # module/__init__.py style
34 fd, fpath, desc = imp.find_module('', [path])
35 mod = imp.load_module(module_name, fd, fpath, desc)
36 else:
37 mod = imp.load_source(module_name, path)
32 else:
38 else:
33 def importh(name):
39 def importh(name):
34 mod = __import__(name)
40 mod = __import__(name)
@@ -29,6 +29,10 b" commands.norepo += ' bar'"
29 EOF
29 EOF
30 abspath=`pwd`/foobar.py
30 abspath=`pwd`/foobar.py
31
31
32 mkdir barfoo
33 cp foobar.py barfoo/__init__.py
34 barfoopath=`pwd`/barfoo
35
32 hg init a
36 hg init a
33 cd a
37 cd a
34 echo foo > file
38 echo foo > file
@@ -43,3 +47,9 b' cd ..'
43 hg clone a b
47 hg clone a b
44
48
45 hg bar
49 hg bar
50
51 echo '% module/__init__.py-style'
52 echo '[extensions]' > $HGRCPATH
53 echo "barfoo = $barfoopath" >> $HGRCPATH
54 cd a
55 hg foo
@@ -13,3 +13,9 b' 1 files updated, 0 files merged, 0 files'
13 uisetup called
13 uisetup called
14 ui.parentui is None
14 ui.parentui is None
15 Bar
15 Bar
16 % module/__init__.py-style
17 uisetup called
18 ui.parentui is None
19 reposetup called for a
20 ui == repo.ui
21 Foo
General Comments 0
You need to be logged in to leave comments. Login now