Show More
@@ -128,15 +128,27 b' def _demandimport(name, globals=None, lo' | |||||
128 | return locals[base] |
|
128 | return locals[base] | |
129 | return _demandmod(name, globals, locals, level) |
|
129 | return _demandmod(name, globals, locals, level) | |
130 | else: |
|
130 | else: | |
131 | if level != -1: |
|
131 | # There is a fromlist. | |
132 |
|
|
132 | # from a import b,c,d | |
|
133 | # from . import b,c,d | |||
|
134 | # from .a import b,c,d | |||
|
135 | ||||
|
136 | # level == -1: relative and absolute attempted (Python 2 only). | |||
|
137 | # level >= 0: absolute only (Python 2 w/ absolute_import and Python 3). | |||
|
138 | # The modern Mercurial convention is to use absolute_import everywhere, | |||
|
139 | # so modern Mercurial code will have level >= 0. | |||
|
140 | ||||
|
141 | if level >= 0: | |||
133 | return _origimport(name, globals, locals, fromlist, level) |
|
142 | return _origimport(name, globals, locals, fromlist, level) | |
134 | # from a import b,c,d |
|
143 | ||
|
144 | # But, we still need to support lazy loading of standard library and 3rd | |||
|
145 | # party modules. So handle level == -1. | |||
135 | mod = _hgextimport(_origimport, name, globals, locals) |
|
146 | mod = _hgextimport(_origimport, name, globals, locals) | |
136 | # recurse down the module chain |
|
147 | # recurse down the module chain | |
137 | for comp in name.split('.')[1:]: |
|
148 | for comp in name.split('.')[1:]: | |
138 | if getattr(mod, comp, nothing) is nothing: |
|
149 | if getattr(mod, comp, nothing) is nothing: | |
139 | setattr(mod, comp, _demandmod(comp, mod.__dict__, mod.__dict__)) |
|
150 | setattr(mod, comp, | |
|
151 | _demandmod(comp, mod.__dict__, mod.__dict__)) | |||
140 | mod = getattr(mod, comp) |
|
152 | mod = getattr(mod, comp) | |
141 | for x in fromlist: |
|
153 | for x in fromlist: | |
142 | # set requested submodules for demand load |
|
154 | # set requested submodules for demand load |
General Comments 0
You need to be logged in to leave comments.
Login now