Show More
@@ -14,6 +14,16 b' import os' | |||||
14 | import sys |
|
14 | import sys | |
15 | import traceback |
|
15 | import traceback | |
16 |
|
16 | |||
|
17 | # Modules that have both Python and C implementations. | |||
|
18 | _dualmodules = ( | |||
|
19 | 'base85.py', | |||
|
20 | 'bdiff.py', | |||
|
21 | 'diffhelpers.py', | |||
|
22 | 'mpatch.py', | |||
|
23 | 'osutil.py', | |||
|
24 | 'parsers.py', | |||
|
25 | ) | |||
|
26 | ||||
17 | def check_compat_py2(f): |
|
27 | def check_compat_py2(f): | |
18 | """Check Python 3 compatibility for a file with Python 2""" |
|
28 | """Check Python 3 compatibility for a file with Python 2""" | |
19 | with open(f, 'rb') as fh: |
|
29 | with open(f, 'rb') as fh: | |
@@ -55,7 +65,9 b' def check_compat_py3(f):' | |||||
55 | # out module paths for things not in a package can be confusing. |
|
65 | # out module paths for things not in a package can be confusing. | |
56 | if f.startswith(('hgext/', 'mercurial/')) and not f.endswith('__init__.py'): |
|
66 | if f.startswith(('hgext/', 'mercurial/')) and not f.endswith('__init__.py'): | |
57 | assert f.endswith('.py') |
|
67 | assert f.endswith('.py') | |
58 |
name = f.replace('/', '.')[:-3] |
|
68 | name = f.replace('/', '.')[:-3] | |
|
69 | if f.endswith(_dualmodules): | |||
|
70 | name = name.replace('.pure.', '.') | |||
59 | try: |
|
71 | try: | |
60 | importlib.import_module(name) |
|
72 | importlib.import_module(name) | |
61 | except Exception as e: |
|
73 | except Exception as e: |
@@ -24,6 +24,16 b' allowsymbolimports = (' | |||||
24 | 'mercurial.node', |
|
24 | 'mercurial.node', | |
25 | ) |
|
25 | ) | |
26 |
|
26 | |||
|
27 | # Modules that have both Python and C implementations. | |||
|
28 | _dualmodules = ( | |||
|
29 | 'base85.py', | |||
|
30 | 'bdiff.py', | |||
|
31 | 'diffhelpers.py', | |||
|
32 | 'mpatch.py', | |||
|
33 | 'osutil.py', | |||
|
34 | 'parsers.py', | |||
|
35 | ) | |||
|
36 | ||||
27 | # Modules that must be aliased because they are commonly confused with |
|
37 | # Modules that must be aliased because they are commonly confused with | |
28 | # common variables and can create aliasing and readability issues. |
|
38 | # common variables and can create aliasing and readability issues. | |
29 | requirealias = { |
|
39 | requirealias = { | |
@@ -691,7 +701,8 b' def main(argv):' | |||||
691 | used_imports = {} |
|
701 | used_imports = {} | |
692 | any_errors = False |
|
702 | any_errors = False | |
693 | for source_path in argv[1:]: |
|
703 | for source_path in argv[1:]: | |
694 | modname = dotted_name_of_path(source_path, trimpure=True) |
|
704 | trimpure = source_path.endswith(_dualmodules) | |
|
705 | modname = dotted_name_of_path(source_path, trimpure=trimpure) | |||
695 | localmods[modname] = source_path |
|
706 | localmods[modname] = source_path | |
696 | for localmodname, source_path in sorted(localmods.items()): |
|
707 | for localmodname, source_path in sorted(localmods.items()): | |
697 | for src, modname, name, line in sources(source_path, localmodname): |
|
708 | for src, modname, name, line in sources(source_path, localmodname): |
@@ -165,7 +165,8 b' if sys.version_info[0] >= 3:' | |||||
165 | if not spec: |
|
165 | if not spec: | |
166 | return None |
|
166 | return None | |
167 |
|
167 | |||
168 |
if fullname.startswith('mercurial.pure.') |
|
168 | if (fullname.startswith('mercurial.pure.') | |
|
169 | and fullname.replace('.pure.', '.') in _dualmodules): | |||
169 | spec.name = spec.name.replace('.pure.', '.') |
|
170 | spec.name = spec.name.replace('.pure.', '.') | |
170 |
|
171 | |||
171 | # TODO need to support loaders from alternate specs, like zip |
|
172 | # TODO need to support loaders from alternate specs, like zip |
General Comments 0
You need to be logged in to leave comments.
Login now