mercurial/demandload.py
author Bryan O'Sullivan <bos@serpentine.com>
Fri, 29 Jul 2005 15:02:27 -0800
changeset 813 80fd2958235a
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
Adapt commit to use file matching code. The code is slightly complicated by the need to commit all outstanding changes in the repository if no file names are given (other commands operate on the current directory and its subdirectories in this case). localrepository.changes has acquired an optional match parameter, to let it filter out include/exclude options.

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