Patchwork [4,of,6,v4] debuginstall: expose modulepolicy

login
register
mail settings
Submitter timeless
Date May 11, 2016, 5:18 p.m.
Message ID <65825180761f1e2bacbe.1462987094@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/15023/
State Superseded, archived
Commit b3a677c82a35e499e84f69245f65e682c4be698f
Delegated to: Yuya Nishihara
Headers show

Comments

timeless - May 11, 2016, 5:18 p.m.
# HG changeset patch
# User timeless <timeless@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
Augie Fackler - May 24, 2016, 2:57 p.m.
On Wed, May 11, 2016 at 05:18:14PM +0000, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@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

This patch doesn't apply, even when I apply the stack over the parent
specified in patch 1.

I've queued the first 3, since they all seem very reasonable. I'd like
to take this one too, and haven't given 5 and 6 thought. Can you
rebase 4::6 and resend them?

Thanks!

>
> 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@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)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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@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)