Patchwork D350: demandimport: test whether to enable or not in hg script

login
register
mail settings
Submitter phabricator
Date Aug. 11, 2017, 6:24 p.m.
Message ID <differential-rev-PHID-DREV-spyilwa6uwq42toj2ge2-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/22885/
State Superseded
Headers show

Comments

phabricator - Aug. 11, 2017, 6:24 p.m.
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This allows us to avoid side effects caused by importing demandimport if
  demandimport is disabled. It also gives the hg script more control about
  choosing whether to enable or disable demandimport.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hg

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel
phabricator - Aug. 15, 2017, 6:59 a.m.
yuja added a comment.


  Seems fine, but what is the "side effects caused by importing demandimport" ?

REPOSITORY
  rHG Mercurial

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

To: quark, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - Aug. 15, 2017, 3:13 p.m.
quark added a comment.


  `sys.modules['hgdemandimport']` being set? Maybe I should remove it from commit message.

REPOSITORY
  rHG Mercurial

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

To: quark, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - Aug. 16, 2017, 2:46 a.m.
yuja added a comment.


  > `sys.modules['hgdemandimport']` being set? Maybe I should remove it from commit message.
  
  So there's no point to duplicate the HGDEMANDIMPORT check?

REPOSITORY
  rHG Mercurial

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

To: quark, #hg-reviewers
Cc: yuja, mercurial-devel
phabricator - Aug. 16, 2017, 3:44 a.m.
quark abandoned this revision.
quark added a comment.


  > So there's no point to duplicate the HGDEMANDIMPORT check?
  
  Hmm... I cannot remember why I did this at the first place. Just checking chg alone should be enough.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -28,8 +28,9 @@ 
 
 # enable importing on demand to reduce startup time
 try:
-    if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
-        import hgdemandimport; hgdemandimport.enable()
+    if os.environ.get('HGDEMANDIMPORT') != 'disable':
+        if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
+            import hgdemandimport; hgdemandimport.enable()
 except ImportError:
     sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
                      ' '.join(sys.path))