[PATCH 2 of 7 v2] hghave: check the mercurial.modulepolicy for pure
Yuya Nishihara
yuya at tcha.org
Fri Jan 15 06:39:11 CST 2016
On Mon, 11 Jan 2016 23:23:04 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1452574111 0
> # Tue Jan 12 04:48:31 2016 +0000
> # Node ID a55eb78c1f0697d658ba78f67641746a4bf119e5
> # Parent 39122c2442cd445172d7f07adb3f8186f9ddc0f1
> hghave: check the mercurial.modulepolicy for pure
>
> This is the most "correct" way to find out if we are running pure,
> but I am not sure about paths/loading the mercurial module in hghave...
>
> diff --git a/tests/hghave.py b/tests/hghave.py
> --- a/tests/hghave.py
> +++ b/tests/hghave.py
> @@ -460,6 +460,14 @@
>
> @check("pure", "running with pure Python code")
> def has_pure():
> + try:
> + parent = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
> + sys.path.insert(0, parent)
> + import mercurial
> + if mercurial.modulepolicy == 'py':
> + return True
> + finally:
> + del sys.path[0]
Perhaps we can expose the module policy by "hg debuginstall" or something.
I think that is one good reason we've introduced the custom importer.
More information about the Mercurial-devel
mailing list