Patchwork [1,of,6] hghave: check the mercurial.modulepolicy for pure

login
register
mail settings
Submitter timeless@mozdev.org
Date March 8, 2016, 5:33 a.m.
Message ID <49a623b73dd3cceb46f0.1457415199@waste.org>
Download mbox | patch
Permalink /patch/13664/
State Accepted
Headers show

Comments

timeless@mozdev.org - March 8, 2016, 5:33 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1452574111 0
#      Tue Jan 12 04:48:31 2016 +0000
# Node ID 49a623b73dd3cceb46f088006d005e2314c056bb
# Parent  9974b8236cac50945d7b529e7c4fae9cf4974443
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...
Yuya Nishihara - March 9, 2016, 2:03 p.m.
On Mon, 07 Mar 2016 23:33:19 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1452574111 0
> #      Tue Jan 12 04:48:31 2016 +0000
> # Node ID 49a623b73dd3cceb46f088006d005e2314c056bb
> # Parent  9974b8236cac50945d7b529e7c4fae9cf4974443
> 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
> @@ -445,6 +445,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

Have you tried "hg debuginstall" I suggested before?
timeless - March 9, 2016, 3:05 p.m.
(py)[timeless@gcc2-power8 tests]$ hg debuginstall
checking encoding (UTF-8)...
checking Python executable (/home/timeless/hg/py/bin/python)
checking Python version (2.7.8)
checking Python lib (/home/timeless/hg/py/lib64/python2.7)...
checking installed modules (/home/timeless/hg/crew/mercurial)...
checking templates (/home/timeless/hg/crew/mercurial/templates)...
checking commit editor...
checking username...
no problems detected

There's no indication of pure. It could be used to parse out installed
modules directory, although I'd rather have it support -T so i could
ask for it directly. And at that point, it would be better for
debuginstall to report the modulepolicy.

I'm ok with doing something else.

On Wed, Mar 9, 2016 at 9:03 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> On Mon, 07 Mar 2016 23:33:19 -0600, timeless wrote:
>> # HG changeset patch
>> # User timeless <timeless@mozdev.org>
>> # Date 1452574111 0
>> #      Tue Jan 12 04:48:31 2016 +0000
>> # Node ID 49a623b73dd3cceb46f088006d005e2314c056bb
>> # Parent  9974b8236cac50945d7b529e7c4fae9cf4974443
>> 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
>> @@ -445,6 +445,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
>
> Have you tried "hg debuginstall" I suggested before?
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - March 9, 2016, 3:37 p.m.
On Wed, 9 Mar 2016 10:05:33 -0500, timeless wrote:
> (py)[timeless@gcc2-power8 tests]$ hg debuginstall
> checking encoding (UTF-8)...
> checking Python executable (/home/timeless/hg/py/bin/python)
> checking Python version (2.7.8)
> checking Python lib (/home/timeless/hg/py/lib64/python2.7)...
> checking installed modules (/home/timeless/hg/crew/mercurial)...
> checking templates (/home/timeless/hg/crew/mercurial/templates)...
> checking commit editor...
> checking username...
> no problems detected
> 
> There's no indication of pure.

I think it should report if we're running pure or not.

> It could be used to parse out installed
> modules directory, although I'd rather have it support -T so i could
> ask for it directly. And at that point, it would be better for
> debuginstall to report the modulepolicy.

Sounds promising.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -445,6 +445,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]
     return any([
         os.environ.get("HGMODULEPOLICY") == "py",
         os.environ.get("HGTEST_RUN_TESTS_PURE") == "--pure",