##// 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 5 # This software may be used and distributed according to the terms
6 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 10 from i18n import _
10 11
11 12 _extensions = {}
@@ -28,7 +29,12 b' def load(ui, name, path):'
28 29 # choose an unique name so that it doesn't
29 30 # conflicts with other modules
30 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 38 else:
33 39 def importh(name):
34 40 mod = __import__(name)
@@ -29,6 +29,10 b" commands.norepo += ' bar'"
29 29 EOF
30 30 abspath=`pwd`/foobar.py
31 31
32 mkdir barfoo
33 cp foobar.py barfoo/__init__.py
34 barfoopath=`pwd`/barfoo
35
32 36 hg init a
33 37 cd a
34 38 echo foo > file
@@ -43,3 +47,9 b' cd ..'
43 47 hg clone a b
44 48
45 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 13 uisetup called
14 14 ui.parentui is None
15 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