Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/demandimport.py @ 28175:c25e3fd38ff1
demandimport: enforce ignore list while processing modules in fromlist
If a module is loaded as "from . import x" form, there has been no way to
disable demand loading for that module because name is ''. This patch makes
it possible to prevent demand loading by '<package-name>.x'.
We don't use _hgextimport(_origimport) here since attr is known to be a
sub-module name. Adding hgext_ to attr wouldn't make sense.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 06 Feb 2016 19:09:10 +0900 |
parents | ffb1ab1e4bba |
children | 9ff7261cc0f5 |
comparison
equal
deleted
inserted
replaced
28174:f16b84b1e40e | 28175:c25e3fd38ff1 |
---|---|
172 If the symbol doesn't exist in the parent module, it must be a | 172 If the symbol doesn't exist in the parent module, it must be a |
173 module. We set missing modules up as _demandmod instances. | 173 module. We set missing modules up as _demandmod instances. |
174 """ | 174 """ |
175 symbol = getattr(mod, attr, nothing) | 175 symbol = getattr(mod, attr, nothing) |
176 if symbol is nothing: | 176 if symbol is nothing: |
177 symbol = _demandmod(attr, mod.__dict__, locals, level=1) | 177 mn = '%s.%s' % (mod.__name__, attr) |
178 if mn in ignore: | |
179 importfunc = _origimport | |
180 else: | |
181 importfunc = _demandmod | |
182 symbol = importfunc(attr, mod.__dict__, locals, level=1) | |
178 setattr(mod, attr, symbol) | 183 setattr(mod, attr, symbol) |
179 | 184 |
180 # Record the importing module references this symbol so we can | 185 # Record the importing module references this symbol so we can |
181 # replace the symbol with the actual module instance at load | 186 # replace the symbol with the actual module instance at load |
182 # time. | 187 # time. |