Show More
@@ -0,0 +1,40 b'' | |||||
|
1 | # policy.py - module policy logic for Mercurial. | |||
|
2 | # | |||
|
3 | # Copyright 2015 Gregory Szorc <gregory.szorc@gmail.com> | |||
|
4 | # | |||
|
5 | # This software may be used and distributed according to the terms of the | |||
|
6 | # GNU General Public License version 2 or any later version. | |||
|
7 | ||||
|
8 | from __future__ import absolute_import | |||
|
9 | ||||
|
10 | import os | |||
|
11 | import sys | |||
|
12 | ||||
|
13 | # Rules for how modules can be loaded. Values are: | |||
|
14 | # | |||
|
15 | # c - require C extensions | |||
|
16 | # allow - allow pure Python implementation when C loading fails | |||
|
17 | # py - only load pure Python modules | |||
|
18 | # | |||
|
19 | # By default, require the C extensions for performance reasons. | |||
|
20 | policy = 'c' | |||
|
21 | try: | |||
|
22 | from . import __modulepolicy__ | |||
|
23 | policy = __modulepolicy__.modulepolicy | |||
|
24 | except ImportError: | |||
|
25 | pass | |||
|
26 | ||||
|
27 | # PyPy doesn't load C extensions. | |||
|
28 | # | |||
|
29 | # The canonical way to do this is to test platform.python_implementation(). | |||
|
30 | # But we don't import platform and don't bloat for it here. | |||
|
31 | if '__pypy__' in sys.builtin_module_names: | |||
|
32 | policy = 'py' | |||
|
33 | ||||
|
34 | # Our C extensions aren't yet compatible with Python 3. So use pure Python | |||
|
35 | # on Python 3 for now. | |||
|
36 | if sys.version_info[0] >= 3: | |||
|
37 | policy = 'py' | |||
|
38 | ||||
|
39 | # Environment variable can always force settings. | |||
|
40 | policy = os.environ.get('HGMODULEPOLICY', policy) |
@@ -12,36 +12,13 b' import os' | |||||
12 | import sys |
|
12 | import sys | |
13 | import zipimport |
|
13 | import zipimport | |
14 |
|
14 | |||
|
15 | from . import ( | |||
|
16 | policy | |||
|
17 | ) | |||
|
18 | ||||
15 | __all__ = [] |
|
19 | __all__ = [] | |
16 |
|
20 | |||
17 | # Rules for how modules can be loaded. Values are: |
|
21 | modulepolicy = policy.policy | |
18 | # |
|
|||
19 | # c - require C extensions |
|
|||
20 | # allow - allow pure Python implementation when C loading fails |
|
|||
21 | # py - only load pure Python modules |
|
|||
22 | # |
|
|||
23 | # By default, require the C extensions for performance reasons. |
|
|||
24 | modulepolicy = 'c' |
|
|||
25 | try: |
|
|||
26 | from . import __modulepolicy__ |
|
|||
27 | modulepolicy = __modulepolicy__.modulepolicy |
|
|||
28 | except ImportError: |
|
|||
29 | pass |
|
|||
30 |
|
||||
31 | # PyPy doesn't load C extensions. |
|
|||
32 | # |
|
|||
33 | # The canonical way to do this is to test platform.python_implementation(). |
|
|||
34 | # But we don't import platform and don't bloat for it here. |
|
|||
35 | if '__pypy__' in sys.builtin_module_names: |
|
|||
36 | modulepolicy = 'py' |
|
|||
37 |
|
||||
38 | # Our C extensions aren't yet compatible with Python 3. So use pure Python |
|
|||
39 | # on Python 3 for now. |
|
|||
40 | if sys.version_info[0] >= 3: |
|
|||
41 | modulepolicy = 'py' |
|
|||
42 |
|
||||
43 | # Environment variable can always force settings. |
|
|||
44 | modulepolicy = os.environ.get('HGMODULEPOLICY', modulepolicy) |
|
|||
45 |
|
22 | |||
46 | # Modules that have both Python and C implementations. See also the |
|
23 | # Modules that have both Python and C implementations. See also the | |
47 | # set of .py files under mercurial/pure/. |
|
24 | # set of .py files under mercurial/pure/. |
@@ -59,6 +59,7 b' from . import (' | |||||
59 | obsolete, |
|
59 | obsolete, | |
60 | patch, |
|
60 | patch, | |
61 | phases, |
|
61 | phases, | |
|
62 | policy, | |||
62 | pvec, |
|
63 | pvec, | |
63 | repair, |
|
64 | repair, | |
64 | revlog, |
|
65 | revlog, | |
@@ -2749,6 +2750,8 b' def debuginstall(ui, **opts):' | |||||
2749 | '+'.join(hgver.split('+')[1:])) |
|
2750 | '+'.join(hgver.split('+')[1:])) | |
2750 |
|
2751 | |||
2751 | # compiled modules |
|
2752 | # compiled modules | |
|
2753 | fm.write('hgmodulepolicy', _("checking module policy (%s)\n"), | |||
|
2754 | policy.policy) | |||
2752 | fm.write('hgmodules', _("checking installed modules (%s)...\n"), |
|
2755 | fm.write('hgmodules', _("checking installed modules (%s)...\n"), | |
2753 | os.path.dirname(__file__)) |
|
2756 | os.path.dirname(__file__)) | |
2754 |
|
2757 |
@@ -6,6 +6,7 b' hg debuginstall' | |||||
6 | checking Python lib (*lib*)... (glob) |
|
6 | checking Python lib (*lib*)... (glob) | |
7 | checking Mercurial version (*) (glob) |
|
7 | checking Mercurial version (*) (glob) | |
8 | checking Mercurial custom build (*) (glob) |
|
8 | checking Mercurial custom build (*) (glob) | |
|
9 | checking module policy (*) (glob) | |||
9 | checking installed modules (*mercurial)... (glob) |
|
10 | checking installed modules (*mercurial)... (glob) | |
10 | checking templates (*mercurial?templates)... (glob) |
|
11 | checking templates (*mercurial?templates)... (glob) | |
11 | checking default template (*mercurial?templates?map-cmdline.default) (glob) |
|
12 | checking default template (*mercurial?templates?map-cmdline.default) (glob) | |
@@ -25,6 +26,7 b' hg debuginstall JSON' | |||||
25 | "encoding": "ascii", |
|
26 | "encoding": "ascii", | |
26 | "encodingerror": null, |
|
27 | "encodingerror": null, | |
27 | "extensionserror": null, |
|
28 | "extensionserror": null, | |
|
29 | "hgmodulepolicy": "*", (glob) | |||
28 | "hgmodules": "*mercurial", (glob) |
|
30 | "hgmodules": "*mercurial", (glob) | |
29 | "hgver": "*", (glob) |
|
31 | "hgver": "*", (glob) | |
30 | "hgverextra": "*", (glob) |
|
32 | "hgverextra": "*", (glob) | |
@@ -47,6 +49,7 b' hg debuginstall with no username' | |||||
47 | checking Python lib (*lib*)... (glob) |
|
49 | checking Python lib (*lib*)... (glob) | |
48 | checking Mercurial version (*) (glob) |
|
50 | checking Mercurial version (*) (glob) | |
49 | checking Mercurial custom build (*) (glob) |
|
51 | checking Mercurial custom build (*) (glob) | |
|
52 | checking module policy (*) (glob) | |||
50 | checking installed modules (*mercurial)... (glob) |
|
53 | checking installed modules (*mercurial)... (glob) | |
51 | checking templates (*mercurial?templates)... (glob) |
|
54 | checking templates (*mercurial?templates)... (glob) | |
52 | checking default template (*mercurial?templates?map-cmdline.default) (glob) |
|
55 | checking default template (*mercurial?templates?map-cmdline.default) (glob) | |
@@ -70,6 +73,7 b' path variables are expanded (~ is the sa' | |||||
70 | checking Python lib (*lib*)... (glob) |
|
73 | checking Python lib (*lib*)... (glob) | |
71 | checking Mercurial version (*) (glob) |
|
74 | checking Mercurial version (*) (glob) | |
72 | checking Mercurial custom build (*) (glob) |
|
75 | checking Mercurial custom build (*) (glob) | |
|
76 | checking module policy (*) (glob) | |||
73 | checking installed modules (*mercurial)... (glob) |
|
77 | checking installed modules (*mercurial)... (glob) | |
74 | checking templates (*mercurial?templates)... (glob) |
|
78 | checking templates (*mercurial?templates)... (glob) | |
75 | checking default template (*mercurial?templates?map-cmdline.default) (glob) |
|
79 | checking default template (*mercurial?templates?map-cmdline.default) (glob) |
General Comments 0
You need to be logged in to leave comments.
Login now