Teach demandload how to import as
authorMatt Mackall <mpm@selenic.com>
Mon, 07 Aug 2006 22:35:36 -0500
changeset 2807 a8a7ce1a01a5
parent 2806 0bf22c109cc3
child 2808 30f59f4a327e
Teach demandload how to import as
mercurial/demandload.py
--- a/mercurial/demandload.py	Mon Aug 07 20:54:03 2006 -0500
+++ b/mercurial/demandload.py	Mon Aug 07 22:35:36 2006 -0500
@@ -96,6 +96,7 @@
 
     foo            import foo
     foo bar        import foo, bar
+    foo@bar        import foo as bar
     foo.bar        import foo.bar
     foo:bar        from foo import bar
     foo:bar,quux   from foo import bar, quux
@@ -108,6 +109,9 @@
             mod = mod[:col]
         else:
             fromlist = []
+        as = None
+        if '@' in mod:
+            mod, as = mod.split("@")
         importer = _importer(scope, mod, fromlist)
         if fromlist:
             for name in fromlist:
@@ -126,4 +130,6 @@
                     continue
             else:
                 basemod = mod
-            scope[basemod] = _replacer(importer, basemod)
+            if not as:
+                as = basemod
+            scope[as] = _replacer(importer, as)