diff --git a/contrib/hg-ssh b/contrib/hg-ssh --- a/contrib/hg-ssh +++ b/contrib/hg-ssh @@ -25,6 +25,9 @@ You can use pattern matching of your nor command="cd repos && hg-ssh user/thomas/* projects/{mercurial,foo}" """ +# enable importing on demand to reduce startup time +from mercurial import demandimport; demandimport.enable() + from mercurial import dispatch import sys, os diff --git a/contrib/hgwebdir.fcgi b/contrib/hgwebdir.fcgi --- a/contrib/hgwebdir.fcgi +++ b/contrib/hgwebdir.fcgi @@ -2,6 +2,9 @@ # # An example CGI script to export multiple hgweb repos, edit as necessary +# enable demandloading to reduce startup time +from mercurial import demandimport; demandimport.enable() + # send python tracebacks to the browser if an error occurs: import cgitb cgitb.enable() diff --git a/hg b/hg --- a/hg +++ b/hg @@ -7,5 +7,8 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. +# enable importing on demand to reduce startup time +from mercurial import demandimport; demandimport.enable() + import mercurial.dispatch mercurial.dispatch.run() diff --git a/hgweb.cgi b/hgweb.cgi --- a/hgweb.cgi +++ b/hgweb.cgi @@ -2,6 +2,9 @@ # # An example CGI script to use hgweb, edit as necessary +# enable importing on demand to reduce startup time +from mercurial import demandimport; demandimport.enable() + # send python tracebacks to the browser if an error occurs: import cgitb cgitb.enable() diff --git a/hgwebdir.cgi b/hgwebdir.cgi --- a/hgwebdir.cgi +++ b/hgwebdir.cgi @@ -2,6 +2,9 @@ # # An example CGI script to export multiple hgweb repos, edit as necessary +# enable importing on demand to reduce startup time +from mercurial import demandimport; demandimport.enable() + # send python tracebacks to the browser if an error occurs: import cgitb cgitb.enable() diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -6,7 +6,6 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -from mercurial import demandimport; demandimport.enable() import os, mimetools, cStringIO from mercurial.i18n import gettext as _ from mercurial import ui, hg, util, templater diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -14,8 +14,6 @@ from distutils.core import setup, Extens from distutils.command.install_data import install_data import mercurial.version -import mercurial.demandimport -mercurial.demandimport.enable = lambda: None extra = {}