annotate mercurial/demandload.py @ 706:5107a7b6b14a

Make "hg parents REV" work (again?) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Make "hg parents REV" work (again?) manifest hash: d14db0d23b539ad0b754a51a83926d14f1be9a6e -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFC12adW7P1GVgWeRoRAtknAJ9TeUybLWYWY+Bi2b5grmAspgfemwCeP9cd 6mYSTWIsovCqW59KIrEvVVo= =u5nR -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 15 Jul 2005 08:32:45 +0100
parents 3db700146536
children f3abe0bdccdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
262
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
1 def demandload(scope, modules):
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
2 class d:
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
3 def __getattr__(self, name):
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
4 mod = self.__dict__["mod"]
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
5 scope = self.__dict__["scope"]
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
6 scope[mod] = __import__(mod, scope, scope, [])
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
7 return getattr(scope[mod], name)
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
8
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
9 for m in modules.split():
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
10 dl = d()
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
11 dl.mod = m
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
12 dl.scope = scope
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
13 scope[m] = dl
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
14
3db700146536 implement demand loading hack
mpm@selenic.com
parents:
diff changeset
15