Show More
@@ -71,6 +71,14 b' def loadpath(path, module_name):' | |||||
71 | exc.filename = path # python does not fill this |
|
71 | exc.filename = path # python does not fill this | |
72 | raise |
|
72 | raise | |
73 |
|
73 | |||
|
74 | def _importh(name): | |||
|
75 | """import and return the <name> module""" | |||
|
76 | mod = __import__(name) | |||
|
77 | components = name.split('.') | |||
|
78 | for comp in components[1:]: | |||
|
79 | mod = getattr(mod, comp) | |||
|
80 | return mod | |||
|
81 | ||||
74 | def load(ui, name, path): |
|
82 | def load(ui, name, path): | |
75 | if name.startswith('hgext.') or name.startswith('hgext/'): |
|
83 | if name.startswith('hgext.') or name.startswith('hgext/'): | |
76 | shortname = name[6:] |
|
84 | shortname = name[6:] | |
@@ -87,20 +95,14 b' def load(ui, name, path):' | |||||
87 | # conflicts with other modules |
|
95 | # conflicts with other modules | |
88 | mod = loadpath(path, 'hgext.%s' % name) |
|
96 | mod = loadpath(path, 'hgext.%s' % name) | |
89 | else: |
|
97 | else: | |
90 | def importh(name): |
|
|||
91 | mod = __import__(name) |
|
|||
92 | components = name.split('.') |
|
|||
93 | for comp in components[1:]: |
|
|||
94 | mod = getattr(mod, comp) |
|
|||
95 | return mod |
|
|||
96 | try: |
|
98 | try: | |
97 | mod = importh("hgext.%s" % name) |
|
99 | mod = _importh("hgext.%s" % name) | |
98 | except ImportError as err: |
|
100 | except ImportError as err: | |
99 | ui.debug('could not import hgext.%s (%s): trying %s\n' |
|
101 | ui.debug('could not import hgext.%s (%s): trying %s\n' | |
100 | % (name, err, name)) |
|
102 | % (name, err, name)) | |
101 | if ui.debugflag: |
|
103 | if ui.debugflag: | |
102 | ui.traceback() |
|
104 | ui.traceback() | |
103 | mod = importh(name) |
|
105 | mod = _importh(name) | |
104 |
|
106 | |||
105 | # Before we do anything with the extension, check against minimum stated |
|
107 | # Before we do anything with the extension, check against minimum stated | |
106 | # compatibility. This gives extension authors a mechanism to have their |
|
108 | # compatibility. This gives extension authors a mechanism to have their |
General Comments 0
You need to be logged in to leave comments.
Login now