# HG changeset patch # User Jun Wu <qu...@fb.com> # Date 1479070477 0 # Sun Nov 13 20:54:37 2016 +0000 # Node ID 70611a6b45d51ba4bf560c2cfdb8d94e08a3dc8f # Parent ca7a76135db4a9b8a90665c8a42013debbdae3b7 chgserve: pre-import extensions
This patch makes chgserve pre-import extensions. It assumes that pre-importing extensions does not have side effects. diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -73,4 +73,26 @@ testedwith = 'ships-with-hg-core' _log = commandserver.log +_preimported = {} # {(name, path): mod} + +def _preimportextensions(ui): + for name, path in ui.configitems('extensions'): + # do not pre-import disabled extensions + if path.startswith('!'): + continue + try: + mod = extensions._importext(name, path) + except ImportError: + pass + else: + _preimported[(name, path)] = mod + ui.debug('chg: pre-imported %s\n' % name) + +def _importext(orig, name, path=None, reportfunc=None): + mod = _preimported.get((name, path)) + if mod: + return mod + else: + return orig(name, path, reportfunc) + def _hashlist(items): """return sha1 hexdigest for a list""" @@ -646,4 +668,5 @@ def uisetup(ui): def _runchgservice(args): ui = uimod.ui() + _preimportextensions(ui) addresses = dispatch._earlygetopt(['--address'], args) @@ -662,3 +685,4 @@ def _runchgservice(args): def run(): + extensions.wrapfunction(extensions, '_importext', _importext) sys.exit(_runchgservice(sys.argv[1:])) _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel