[PATCH 3 of 4 V2] import-checker: remove useless module name supposition in checkmod

Augie Fackler raf at durin42.com
Fri May 15 16:36:37 CDT 2015


> On May 15, 2015, at 10:13, FUJIWARA Katsunori <foozy at lares.dti.ne.jp> wrote:
> 
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1431699038 -32400
> #      Fri May 15 23:10:38 2015 +0900
> # Node ID 0403363ab33ce62c84ab1fc004da081357516362
> # Parent  ab820b3793cc9a2680cc90f11fd760750c276adb
> import-checker: remove useless module name supposition in checkmod
> 
> Previous patch ensures that all module names stored in "imports" are
> absolute one, and it makes module name supposition in "checkmod" useless.

I might reword this as:

import-checker: don't look for modules with a mercurial. prefix if not found

The previous patch ensures all module names are recorded in `imports` as absolute names, so we no longer need to re-try modules as mercurial. if they appear to not be from the stdlib.

> 
> diff --git a/contrib/import-checker.py b/contrib/import-checker.py
> --- a/contrib/import-checker.py
> +++ b/contrib/import-checker.py
> @@ -279,8 +279,6 @@ def checkmod(mod, imports):
>     while visit:
>         path = visit.pop(0)
>         for i in sorted(imports.get(path[-1], [])):
> -            if i not in stdlib_modules and not i.startswith('mercurial.'):
> -                i = mod.rsplit('.', 1)[0] + '.' + i
>             if len(path) < shortest.get(i, 1000):
>                 shortest[i] = len(path)
>                 if i in path:
> @@ -302,10 +300,12 @@ def rotatecycle(cycle):
> def find_cycles(imports):
>     """Find cycles in an already-loaded import graph.
> 
> -    >>> imports = {'top.foo': ['bar', 'os.path', 'qux'],
> -    ...            'top.bar': ['baz', 'sys'],
> -    ...            'top.baz': ['foo'],
> -    ...            'top.qux': ['foo']}
> +    All module names contained in `imports` should be absolute one.
> +
> +    >>> imports = {'top.foo': ['top.bar', 'os.path', 'top.qux'],
> +    ...            'top.bar': ['top.baz', 'sys'],
> +    ...            'top.baz': ['top.foo'],
> +    ...            'top.qux': ['top.foo']}
>>>> print '\\n'.join(sorted(find_cycles(imports)))
>     top.bar -> top.baz -> top.foo -> top.bar
>     top.foo -> top.qux -> top.foo
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list