view mercurial/demandload.py @ 690:f762860f82c6

Minor merge fixups return a proper errorlevel on abort let force jump across branches catch exception on unlink manifest hash: 6787814cd75e9f9623c56dc36f865afd54f56bfa
author mpm@selenic.com
date Wed, 13 Jul 2005 01:46:50 -0800
parents 3db700146536
children f3abe0bdccdd
line wrap: on
line source

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