mozext: disable demand importer when importing mozautomation (bug 1242653); r?dminor draft
authorGregory Szorc <gps@mozilla.com>
Mon, 25 Jan 2016 11:40:18 -0800
changeset 6942 e15e1ceb8ce167f66e0e3f50edc2719afecd94bd
parent 6938 5d5a5ea80e992180acf502657a5d91232cb08e62
child 6943 4f496dcf773935034789f7b606e18c65ef84916a
push id550
push usergszorc@mozilla.com
push dateMon, 25 Jan 2016 19:40:33 +0000
reviewersdminor
bugs1242653
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.
hgext/mozext/__init__.py
--- 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 = {}