mercurial/packagescan.py
changeset 2600 c4325f0a9b91
parent 2497 976b6b2a1613
child 2858 345bac2bc4ec
child 2981 0171a5432621
equal deleted inserted replaced
2599:e4b5e48052c6 2600:c4325f0a9b91
    15 
    15 
    16 # Install this module as fake demandload module
    16 # Install this module as fake demandload module
    17 sys.modules['mercurial.demandload'] = sys.modules[__name__]
    17 sys.modules['mercurial.demandload'] = sys.modules[__name__]
    18 
    18 
    19 # Requiredmodules contains the modules imported by demandload.
    19 # Requiredmodules contains the modules imported by demandload.
    20 # Please note that demandload can be invoked before the 
    20 # Please note that demandload can be invoked before the
    21 # mercurial.packagescan.scan method is invoked in case a mercurial
    21 # mercurial.packagescan.scan method is invoked in case a mercurial
    22 # module is imported.
    22 # module is imported.
    23 requiredmodules = {} 
    23 requiredmodules = {}
    24 def demandload(scope, modules):
    24 def demandload(scope, modules):
    25     """ fake demandload function that collects the required modules 
    25     """ fake demandload function that collects the required modules
    26         foo            import foo
    26         foo            import foo
    27         foo bar        import foo, bar
    27         foo bar        import foo, bar
    28         foo.bar        import foo.bar
    28         foo.bar        import foo.bar
    29         foo:bar        from foo import bar
    29         foo:bar        from foo import bar
    30         foo:bar,quux   from foo import bar, quux
    30         foo:bar,quux   from foo import bar, quux
    47             while True:
    47             while True:
    48                 # mn and mod.__name__ might not be the same
    48                 # mn and mod.__name__ might not be the same
    49                 scope[mn] = mod
    49                 scope[mn] = mod
    50                 requiredmodules[mod.__name__] = 1
    50                 requiredmodules[mod.__name__] = 1
    51                 if len(comp) == i: break
    51                 if len(comp) == i: break
    52                 mod = getattr(mod,comp[i]) 
    52                 mod = getattr(mod,comp[i])
    53                 mn = string.join(comp[:i+1],'.')
    53                 mn = string.join(comp[:i+1],'.')
    54                 i += 1
    54                 i += 1
    55         else:
    55         else:
    56             # mod is the last package in the component list
    56             # mod is the last package in the component list
    57             requiredmodules[mod.__name__] = 1
    57             requiredmodules[mod.__name__] = 1