[PATCH 1 of 2] demandimport: enforce ignore list while processing modules in fromlist
Yuya Nishihara
yuya at tcha.org
Sun Feb 21 05:37:51 UTC 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1454753350 -32400
# Sat Feb 06 19:09:10 2016 +0900
# Node ID b7583bf4ed46e7c022467c43c68eea0fc25e4069
# Parent 1f036626b633a057498a619afb9907728a085061
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.
diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
--- a/mercurial/demandimport.py
+++ b/mercurial/demandimport.py
@@ -174,7 +174,12 @@ def _demandimport(name, globals=None, lo
"""
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
More information about the Mercurial-devel
mailing list