# HG changeset patch # User Jun Wu # Date 1502905446 25200 # Node ID 3cfc9070245fbaa8c4c010327f24d579a416370f # Parent 8fb5212652ec1a60522c4d5847fde1c54183a7eb demandimport: disable if chg is being used 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. This is not done by setting `HGDEMANDIMPORT` chg client-side because that has side-effects on child processes (hooks, etc). Differential Revision: https://phab.mercurial-scm.org/D351 diff -r 8fb5212652ec -r 3cfc9070245f hgdemandimport/__init__.py --- a/hgdemandimport/__init__.py Fri Aug 18 11:08:17 2017 -0700 +++ b/hgdemandimport/__init__.py Wed Aug 16 10:44:06 2017 -0700 @@ -73,5 +73,7 @@ deactivated = demandimport.deactivated def enable(): - if os.environ.get('HGDEMANDIMPORT') != 'disable': + # chg pre-imports modules so do not enable demandimport for it + if ('CHGINTERNALMARK' not in os.environ + and os.environ.get('HGDEMANDIMPORT') != 'disable'): demandimport.enable() diff -r 8fb5212652ec -r 3cfc9070245f mercurial/chgserver.py --- a/mercurial/chgserver.py Fri Aug 18 11:08:17 2017 -0700 +++ b/mercurial/chgserver.py Wed Aug 16 10:44:06 2017 -0700 @@ -565,8 +565,11 @@ self._hashstate, self._baseaddress) def chgunixservice(ui, repo, opts): - # CHGINTERNALMARK is temporarily set by chg client to detect if chg will - # start another chg. drop it to avoid possible side effects. + # CHGINTERNALMARK is set by chg client. It is an indication of things are + # started by chg so other code can do things accordingly, like disabling + # demandimport or detecting chg client started by chg client. When executed + # here, CHGINTERNALMARK is no longer useful and hence dropped to make + # environ cleaner. if 'CHGINTERNALMARK' in encoding.environ: del encoding.environ['CHGINTERNALMARK']