D351: demandimport: disable by default if chg is being used

quark (Jun Wu) phabricator at mercurial-scm.org
Fri Aug 11 18:26:59 UTC 2017


quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In chg's case, making modules lazily loaded could actually slow down things
  since chg pre-imports them. Therefore disable demandimport if chg is being
  used. Users could override this behavior by explicitly setting
  HGDEMANDIMPORT.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hg

CHANGE DETAILS

diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -28,7 +28,10 @@
 
 # enable importing on demand to reduce startup time
 try:
-    if os.environ.get('HGDEMANDIMPORT') != 'disable':
+    default = ''
+    if 'CHGINTERNALMARK' in os.environ:
+        default = 'disable'
+    if os.environ.get('HGDEMANDIMPORT', default) != 'disable':
         if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
             import hgdemandimport; hgdemandimport.enable()
 except ImportError:



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


More information about the Mercurial-devel mailing list