# HG changeset patch # User Ali Gholami Rudi # Date 2008-01-16 15:44:54 # Node ID e160f231281594dd51b897861146bf2e111775ef # Parent 3340aa5a64f7fe4ad2b0341951ffcf960a6686d2 demandimport: handling new relative imports Mercurial does not work on python2.6 because __import__ takes an additional argument called level. This patch merely calls the built-in __import__ when level is passed. diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py --- a/mercurial/demandimport.py +++ b/mercurial/demandimport.py @@ -77,7 +77,7 @@ class _demandmod(object): self._load() setattr(self._module, attr, val) -def _demandimport(name, globals=None, locals=None, fromlist=None): +def _demandimport(name, globals=None, locals=None, fromlist=None, level=None): if not locals or name in ignore or fromlist == ('*',): # these cases we can't really delay return _origimport(name, globals, locals, fromlist) @@ -95,6 +95,9 @@ def _demandimport(name, globals=None, lo return locals[base] return _demandmod(name, globals, locals) else: + if level is not None: + # from . import b,c,d or from .a import b,c,d + return _origimport(name, globals, locals, fromlist, level) # from a import b,c,d mod = _origimport(name, globals, locals) # recurse down the module chain