# HG changeset patch # User John Arbash Meinel # Date 1147985575 25200 # Node ID d01eac5968c696ef95e2dba318bc0957f78e7f32 # Parent b2f37c7026ca3f21951d3b6d439094a90d8be92a demandload: implement __call__ demandload can now load functions and classes, and not just modules. (So if you access foo() rather than just foo.* it still works). demandload still doesn't work for constants. diff --git a/mercurial/demandload.py b/mercurial/demandload.py --- a/mercurial/demandload.py +++ b/mercurial/demandload.py @@ -81,6 +81,10 @@ class _replacer_from(_replacer): return getattr(importer.module(), target) + def __call__(self, *args, **kwargs): + target = object.__getattribute__(self, 'module')() + return target(*args, **kwargs) + def demandload(scope, modules): '''import modules into scope when each is first used.