changeset 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 f16b84b1e40e
children 9ff7261cc0f5
files mercurial/demandimport.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/demandimport.py	Mon Feb 15 16:49:52 2016 -0800
+++ b/mercurial/demandimport.py	Sat Feb 06 19:09:10 2016 +0900
@@ -174,7 +174,12 @@
             """
             symbol = getattr(mod, attr, nothing)
             if symbol is nothing:
-                symbol = _demandmod(attr, mod.__dict__, locals, level=1)
+                mn = '%s.%s' % (mod.__name__, attr)
+                if mn in ignore:
+                    importfunc = _origimport
+                else:
+                    importfunc = _demandmod
+                symbol = importfunc(attr, mod.__dict__, locals, level=1)
                 setattr(mod, attr, symbol)
 
             # Record the importing module references this symbol so we can