# HG changeset patch # User Volker Kleinfeld # Date 1155221998 -7200 # Node ID 0171a54326214f9c509a64218567b83578801f92 # Parent 49988d9f07586e55b65175a00626e9a20db094f7 Support the demandload syntax "@" in packagescan diff -r 49988d9f0758 -r 0171a5432621 mercurial/packagescan.py --- a/mercurial/packagescan.py Wed Aug 09 13:55:18 2006 -0500 +++ b/mercurial/packagescan.py Thu Aug 10 16:59:58 2006 +0200 @@ -26,6 +26,7 @@ foo import foo foo bar import foo, bar foo.bar import foo.bar + foo@bar import foo as bar foo:bar from foo import bar foo:bar,quux from foo import bar, quux foo.bar:quux from foo.bar import quux""" @@ -38,6 +39,9 @@ except: module = m fromlist = [] + as = None + if '@' in module: + module, as = module.split("@") mod = __import__(module, scope, scope, fromlist) if fromlist == []: # mod is only the top package, but we need all packages @@ -46,7 +50,9 @@ mn = comp[0] while True: # mn and mod.__name__ might not be the same - scope[mn] = mod + if not as: + as = mn + scope[as] = mod requiredmodules[mod.__name__] = 1 if len(comp) == i: break mod = getattr(mod,comp[i])