mozext: disable demand importer when importing mozautomation (
bug 1242653); r?dminor
Because "requests" doesn't play nice with the demand importer. This
fixes a regression from 4b953dc90fa0.
--- a/hgext/mozext/__init__.py
+++ b/hgext/mozext/__init__.py
@@ -273,16 +273,17 @@ import datetime
import errno
import os
import shutil
import sys
from operator import methodcaller
from mercurial import (
+ demandimport,
exchange,
revset,
templatefilters,
templatekw,
templater,
)
from mercurial.i18n import _
@@ -312,36 +313,44 @@ from mercurial import (
OUR_DIR = os.path.dirname(__file__)
REPO_ROOT = os.path.normpath(os.path.join(OUR_DIR, '..', '..'))
PYLIB = os.path.join(REPO_ROOT, 'pylib')
for p in ('flake8', 'mccabe', 'mozautomation', 'pep8', 'pyflakes'):
sys.path.insert(0, os.path.join(PYLIB, p))
-from mozautomation.changetracker import (
- ChangeTracker,
-)
+# Disable demand importing for mozautomation because "requests" doesn't
+# play nice with the demand importer.
+demandenabled = demandimport.isenabled()
+try:
+ demandimport.disable()
-from mozautomation.commitparser import (
- parse_bugs,
- parse_reviewers,
-)
+ from mozautomation.changetracker import (
+ ChangeTracker,
+ )
-from mozautomation.repository import (
- MercurialRepository,
- RELEASE_TREES,
- REPOS,
- resolve_trees_to_official,
- resolve_trees_to_uris,
- resolve_uri_to_tree,
- treeherder_url,
- TREE_ALIASES,
-)
+ from mozautomation.commitparser import (
+ parse_bugs,
+ parse_reviewers,
+ )
+ from mozautomation.repository import (
+ MercurialRepository,
+ RELEASE_TREES,
+ REPOS,
+ resolve_trees_to_official,
+ resolve_trees_to_uris,
+ resolve_uri_to_tree,
+ treeherder_url,
+ TREE_ALIASES,
+ )
+finally:
+ if demandenabled:
+ demandimport.enable()
bz_available = False
testedwith = '3.1 3.2 3.3 3.4 3.5 3.6'
buglink = 'https://bugzilla.mozilla.org/enter_bug.cgi?product=Developer%20Services&component=Mercurial%3A%20mozext'
commands.norepo += ' cloneunified moztrees treestatus'
cmdtable = {}