Patchwork D445: demandimport: move HGDEMANDIMPORT test to __init__.py

login
register
mail settings
Submitter phabricator
Date Aug. 19, 2017, 6:57 a.m.
Message ID <676db5d605b588ac0bc362a40569980f@localhost.localdomain>
Download mbox | patch
Permalink /patch/23130/
State Not Applicable
Headers show

Comments

phabricator - Aug. 19, 2017, 6:57 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8fb5212652ec: demandimport: move HGDEMANDIMPORT test to __init__.py (authored by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D445?vs=1077&id=1086

REVISION DETAIL
  https://phab.mercurial-scm.org/D445

AFFECTED FILES
  hgdemandimport/__init__.py
  hgdemandimport/demandimportpy2.py
  hgdemandimport/demandimportpy3.py

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgdemandimport/demandimportpy3.py b/hgdemandimport/demandimportpy3.py
--- a/hgdemandimport/demandimportpy3.py
+++ b/hgdemandimport/demandimportpy3.py
@@ -27,7 +27,6 @@ 
 from __future__ import absolute_import
 
 import contextlib
-import os
 import sys
 
 import importlib.abc
@@ -81,8 +80,7 @@ 
         pass
 
 def enable():
-    if os.environ.get('HGDEMANDIMPORT') != 'disable':
-        sys.path_hooks.insert(0, _makefinder)
+    sys.path_hooks.insert(0, _makefinder)
 
 @contextlib.contextmanager
 def deactivated():
diff --git a/hgdemandimport/demandimportpy2.py b/hgdemandimport/demandimportpy2.py
--- a/hgdemandimport/demandimportpy2.py
+++ b/hgdemandimport/demandimportpy2.py
@@ -28,7 +28,6 @@ 
 
 import __builtin__ as builtins
 import contextlib
-import os
 import sys
 
 contextmanager = contextlib.contextmanager
@@ -285,8 +284,7 @@ 
 
 def enable():
     "enable global demand-loading of modules"
-    if os.environ.get('HGDEMANDIMPORT') != 'disable':
-        builtins.__import__ = _demandimport
+    builtins.__import__ = _demandimport
 
 def disable():
     "disable global demand-loading of modules"
diff --git a/hgdemandimport/__init__.py b/hgdemandimport/__init__.py
--- a/hgdemandimport/__init__.py
+++ b/hgdemandimport/__init__.py
@@ -13,6 +13,7 @@ 
 
 from __future__ import absolute_import
 
+import os
 import sys
 
 if sys.version_info[0] >= 3:
@@ -68,6 +69,9 @@ 
 
 # Re-export.
 isenabled = demandimport.isenabled
-enable = demandimport.enable
 disable = demandimport.disable
 deactivated = demandimport.deactivated
+
+def enable():
+    if os.environ.get('HGDEMANDIMPORT') != 'disable':
+        demandimport.enable()