mercurial/demandload.py
author mpm@selenic.com
Wed, 15 Jun 2005 10:02:41 -0800
changeset 355 3e18360a8912
parent 262 3db700146536
child 1826 f3abe0bdccdd
permissions -rw-r--r--
hg import: better file accounting -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hg import: better file accounting From: Chris Mason <mason@suse.com> Change hg import to call hg addremove with the file list to make sure files added/deleted by the patch are properly accounted for. Instead of using lsdiff, the output of patch is parsed directly to find the file list. manifest hash: defed8cb90d6f976fb47949ac03dc4b88870ba77 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsG1BywK+sNU5EO8RAvV9AJ9H25L5vdnZB1xpAakuN3tGuMfRfgCfdAgP 3xBc3S4F74/7DdS2GXRNhGw= =oXXT -----END PGP SIGNATURE-----

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