Commit Graph

11 Commits

Author SHA1 Message Date
Yuya Nishihara
c52484bc8a policy: remove unused policynoc and policynocffi constants 2017-05-02 21:45:48 +09:00
Yuya Nishihara
720bf3b0d8 cffi: split modules from pure
The copyright lines are updated per change history.

cffi/osutil.py isn't tested since I have no access to OS X machine right now,
sorry.
2017-05-02 21:15:31 +09:00
Yuya Nishihara
9fb4289a5c policy: extend API version checks for cffi
This is just a stub for future extension. I could add a version constant to
CFFI modules by putting it to both ffi.set_source() and ffi.cdef(), but that
doesn't seem right. So for now, cffi modules will be explicitly unversioned
(i.e. version constant must be undefined or set to None.) We can revisit it
later when we need to consider CFFI support more seriously.
2017-05-28 15:45:52 +09:00
Jun Wu
714cce3396 policy: define C module versions individually
This allows us to bump the version for a single module without changing all
of them.
2017-05-22 22:59:40 -07:00
Yuya Nishihara
bcb7d6a701 policy: add helper to import cext/pure module
These functions are sysstr API since __import__() and getattr() hate byte
strings on Python 3.

There's a minor BC, which is ImportError will be raised if invalid
HGMODULEPOLICY is specified. I think this is more desired behavior.

We're planning to add strict checking for C API compatibility. This patch
includes the stub for it.
2016-08-12 11:30:17 +09:00
Yuya Nishihara
2fe12e4917 policy: relax the default for in-place build
We're going to make the 'c' policy more strict, where no missing attribute
will be allowed. Since we want to run 'hg bisect' without rebuilding the C
extension modules, we'll need a looser policy for development environment.

The default for system installation isn't changed.

Note that the current 'c' policy is practically 'allow'-ish as we have lots
of adhoc fallbacks to pure functions.
2017-04-26 23:02:43 +09:00
Yuya Nishihara
6a96222913 policy: mark all string literals as sysstr or bytes
The policy module won't be imported early in future, which means string
literals will be processed by our Python 3 loader.
2017-05-02 18:35:09 +09:00
FUJIWARA Katsunori
9d450170ba py3: add "b" prefix to string literals related to module policy
String literals without explicit prefix in __init__.py and policy.py
are treated as unicode object on Python3, because these modules are
loaded before setup of our specific code transformation (the later
module is imported at the beginning of __init__.py).

BTW, "modulepolicy" in __init__.py is initialized by "policy.policy".

This causes issues below;

  - checking "policy" value in other modules causes unintentional result

    For example, "b'py' not in (u'c', u'py')" returns True
    unintentionally on Python3.

  - writing "policy" out fails at conversion from unicode to bytes

    db1ebf457295 fixed this issue for default code path, but "policy"
    can be overridden by HGMODULEPOLICY environment variable (it should
    be rare case for developer using Python3, though).

This patch does:

  - add "b" prefix to all string literals, which are related to module
    policy, in modules above.

  - check existence of HGMODULEPOLICY, and overwrite "policy" only if
    it exists

    For simplicity, this patch omits checking "supports_bytes_environ",
    switching os.environ/os.environb, and so on (Yuya agreed this in
    personal talking)
2017-03-13 04:06:36 +09:00
Augie Fackler
f3d54c952b policy: try and always have a bytes for module policy
debuginstall now runs cleanly in Python 3.
2017-03-08 18:11:41 -05:00
Maciej Fijalkowski
7f30335cfb policy: add cffi policy for PyPy
This adds cffi policy in the case where we don't want to use C modules,
but instead we're happy to rely on cffi (bundled with pypy)
2016-06-07 15:35:58 +02:00
timeless
0dcdb26a9d debuginstall: expose modulepolicy
With this, you can check for pure easily:
$ HGMODULEPOLICY=py ./hg debuginstall -T "{hgmodulepolicy}"
py
2016-03-09 19:55:45 +00:00