[PATCH 4 of 6 v4] debuginstall: expose modulepolicy
timeless
timeless at fmr.im
Wed May 11 13:18:14 EDT 2016
# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1457553345 0
# Wed Mar 09 19:55:45 2016 +0000
# Node ID 65825180761f1e2bacbe8def2e0d502bf17b5e07
# Parent f08636bb41265409e5fbdc7376cd4032d9a680a1
# EXP-Topic runtests
# Available At bb://timeless/mercurial-crew
# hg pull bb://timeless/mercurial-crew -r 65825180761f
debuginstall: expose modulepolicy
With this, you can check for pure easily:
$ HGMODULEPOLICY=py ./hg debuginstall -T "{hgmodulepolicy}"
py
diff -r f08636bb4126 -r 65825180761f mercurial/__init__.py
--- a/mercurial/__init__.py Wed May 11 15:20:25 2016 +0000
+++ b/mercurial/__init__.py Wed Mar 09 19:55:45 2016 +0000
@@ -12,36 +12,13 @@
import sys
import zipimport
+from . import (
+ policy
+)
+
__all__ = []
-# Rules for how modules can be loaded. Values are:
-#
-# c - require C extensions
-# allow - allow pure Python implementation when C loading fails
-# py - only load pure Python modules
-#
-# By default, require the C extensions for performance reasons.
-modulepolicy = 'c'
-try:
- from . import __modulepolicy__
- modulepolicy = __modulepolicy__.modulepolicy
-except ImportError:
- pass
-
-# PyPy doesn't load C extensions.
-#
-# The canonical way to do this is to test platform.python_implementation().
-# But we don't import platform and don't bloat for it here.
-if '__pypy__' in sys.builtin_module_names:
- modulepolicy = 'py'
-
-# Our C extensions aren't yet compatible with Python 3. So use pure Python
-# on Python 3 for now.
-if sys.version_info[0] >= 3:
- modulepolicy = 'py'
-
-# Environment variable can always force settings.
-modulepolicy = os.environ.get('HGMODULEPOLICY', modulepolicy)
+modulepolicy = policy.policy
# Modules that have both Python and C implementations. See also the
# set of .py files under mercurial/pure/.
diff -r f08636bb4126 -r 65825180761f mercurial/commands.py
--- a/mercurial/commands.py Wed May 11 15:20:25 2016 +0000
+++ b/mercurial/commands.py Wed Mar 09 19:55:45 2016 +0000
@@ -59,6 +59,7 @@
obsolete,
patch,
phases,
+ policy,
pvec,
repair,
revlog,
@@ -2741,6 +2742,8 @@
os.path.dirname(os.__file__))
# compiled modules
+ fm.write('hgmodulepolicy', _("checking module policy (%s)\n"),
+ policy.policy)
fm.write('hgmodules', _("checking installed modules (%s)...\n"),
os.path.dirname(__file__))
diff -r f08636bb4126 -r 65825180761f mercurial/policy.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial/policy.py Wed Mar 09 19:55:45 2016 +0000
@@ -0,0 +1,40 @@
+# policy.py - module policy logic for Mercurial.
+#
+# Copyright 2015 Gregory Szorc <gregory.szorc at gmail.com>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+
+import os
+import sys
+
+# Rules for how modules can be loaded. Values are:
+#
+# c - require C extensions
+# allow - allow pure Python implementation when C loading fails
+# py - only load pure Python modules
+#
+# By default, require the C extensions for performance reasons.
+policy = 'c'
+try:
+ from . import __modulepolicy__
+ policy = __modulepolicy__.modulepolicy
+except ImportError:
+ pass
+
+# PyPy doesn't load C extensions.
+#
+# The canonical way to do this is to test platform.python_implementation().
+# But we don't import platform and don't bloat for it here.
+if '__pypy__' in sys.builtin_module_names:
+ policy = 'py'
+
+# Our C extensions aren't yet compatible with Python 3. So use pure Python
+# on Python 3 for now.
+if sys.version_info[0] >= 3:
+ policy = 'py'
+
+# Environment variable can always force settings.
+policy = os.environ.get('HGMODULEPOLICY', policy)
diff -r f08636bb4126 -r 65825180761f tests/test-install.t
--- a/tests/test-install.t Wed May 11 15:20:25 2016 +0000
+++ b/tests/test-install.t Wed Mar 09 19:55:45 2016 +0000
@@ -4,6 +4,7 @@
checking Python executable (*) (glob)
checking Python version (2.*) (glob)
checking Python lib (*lib*)... (glob)
+ checking module policy (*) (glob)
checking installed modules (*mercurial)... (glob)
checking templates (*mercurial?templates)... (glob)
checking default template (*mercurial?templates?map-cmdline.default) (glob)
@@ -23,6 +24,7 @@
"encoding": "ascii",
"encodingerror": null,
"extensionserror": null,
+ "hgmodulepolicy": "*", (glob)
"hgmodules": "*mercurial", (glob)
"problems": 0,
"pythonexe": "*", (glob)
@@ -41,6 +43,7 @@
checking Python executable (*) (glob)
checking Python version (2.*) (glob)
checking Python lib (*lib*)... (glob)
+ checking module policy (*) (glob)
checking installed modules (*mercurial)... (glob)
checking templates (*mercurial?templates)... (glob)
checking default template (*mercurial?templates?map-cmdline.default) (glob)
@@ -62,6 +65,7 @@
checking Python executable (*) (glob)
checking Python version (*) (glob)
checking Python lib (*lib*)... (glob)
+ checking module policy (*) (glob)
checking installed modules (*mercurial)... (glob)
checking templates (*mercurial?templates)... (glob)
checking default template (*mercurial?templates?map-cmdline.default) (glob)
More information about the Mercurial-devel
mailing list