mercurial/demandload.py
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
Tue, 21 Feb 2006 23:21:15 +0100
changeset 1787 e431344e604c
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
add a timeout when a lock is held (default 1024 sec) - change the wait keyword from lock.lock to timeout, a negative timeout of means "wait forever" - refactor the two lock functions from localrepo.py - make them use the timeout (default 1024, can be changed with ui.timeout in the config file - update the doc

def demandload(scope, modules):
    class d:
        def __getattr__(self, name):
            mod = self.__dict__["mod"]
            scope = self.__dict__["scope"]
            scope[mod] = __import__(mod, scope, scope, [])
            return getattr(scope[mod], name)

    for m in modules.split():
        dl = d()
        dl.mod = m
        dl.scope = scope
        scope[m] = dl