Show More
@@ -14,6 +14,16 b' import os' | |||
|
14 | 14 | import sys |
|
15 | 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 | 27 | def check_compat_py2(f): |
|
18 | 28 | """Check Python 3 compatibility for a file with Python 2""" |
|
19 | 29 | with open(f, 'rb') as fh: |
@@ -55,7 +65,9 b' def check_compat_py3(f):' | |||
|
55 | 65 | # out module paths for things not in a package can be confusing. |
|
56 | 66 | if f.startswith(('hgext/', 'mercurial/')) and not f.endswith('__init__.py'): |
|
57 | 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 | 71 | try: |
|
60 | 72 | importlib.import_module(name) |
|
61 | 73 | except Exception as e: |
@@ -24,6 +24,16 b' allowsymbolimports = (' | |||
|
24 | 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 | 37 | # Modules that must be aliased because they are commonly confused with |
|
28 | 38 | # common variables and can create aliasing and readability issues. |
|
29 | 39 | requirealias = { |
@@ -691,7 +701,8 b' def main(argv):' | |||
|
691 | 701 | used_imports = {} |
|
692 | 702 | any_errors = False |
|
693 | 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 | 706 | localmods[modname] = source_path |
|
696 | 707 | for localmodname, source_path in sorted(localmods.items()): |
|
697 | 708 | for src, modname, name, line in sources(source_path, localmodname): |
@@ -165,7 +165,8 b' if sys.version_info[0] >= 3:' | |||
|
165 | 165 | if not spec: |
|
166 | 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 | 170 | spec.name = spec.name.replace('.pure.', '.') |
|
170 | 171 | |
|
171 | 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