reviewboard: use demandimport.deactivated; r?smacleod draft
authorGregory Szorc <gps@mozilla.com>
Mon, 21 Dec 2015 14:26:27 -0800
changeset 6720 0a35fe8105d07422beb9238f25fb47966fa02587
parent 6718 7fd4fa6a1e1995f16658c4d7a59260ed52d0241a
child 6721 5904e2c44f82eca70ff648a59553056477c9924b
push id514
push usergszorc@mozilla.com
push dateWed, 13 Jan 2016 02:14:28 +0000
reviewerssmacleod
reviewboard: use demandimport.deactivated; r?smacleod This is the proper way to temporarily deactivate demandimport, as it will restore the previous state instead of assuming it was enabled to begin with.
hgext/reviewboard/server.py
--- a/hgext/reviewboard/server.py
+++ b/hgext/reviewboard/server.py
@@ -37,23 +37,22 @@ from mercurial.i18n import _
 from mercurial.node import (
     hex,
     nullid,
 )
 
 OUR_DIR = os.path.normpath(os.path.dirname(__file__))
 execfile(os.path.join(OUR_DIR, '..', 'bootstrap.py'))
 
-demandimport.disable()
-try:
-    import hgrb.proto
-except ImportError:
-    sys.path.insert(0, OUR_DIR)
-    import hgrb.proto
-demandimport.enable()
+with demandimport.deactivated():
+    try:
+        import hgrb.proto
+    except ImportError:
+        sys.path.insert(0, OUR_DIR)
+        import hgrb.proto
 
 testedwith = '3.3 3.4 3.5 3.6'
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
 
 
 # Capabilities the server requires in clients.