Patchwork [4,of,6] mercurial: check mercurial/modulepolicy for modulepolicy

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

Comments

timeless@mozdev.org - March 8, 2016, 5:33 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1452574998 0
#      Tue Jan 12 05:03:18 2016 +0000
# Node ID 6f8152b11dc36ea701c8a6a247cd3bbed4c53ca1
# Parent  87c23b43ccb5387c236ea1624822dd54392bc73d
mercurial: check mercurial/modulepolicy for modulepolicy

On local pure systems, setup doesn't rewrite mercurial/__init__.py,
because the file is managed by Mercurial...

In order to let such systems work, we allow for a file:
mercurial/modulepolicy to determine the policy.

A later patch will have setup.py write to this file.
Yuya Nishihara - March 9, 2016, 2:10 p.m.
On Mon, 07 Mar 2016 23:33:22 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1452574998 0
> #      Tue Jan 12 05:03:18 2016 +0000
> # Node ID 6f8152b11dc36ea701c8a6a247cd3bbed4c53ca1
> # Parent  87c23b43ccb5387c236ea1624822dd54392bc73d
> mercurial: check mercurial/modulepolicy for modulepolicy
> 
> On local pure systems, setup doesn't rewrite mercurial/__init__.py,
> because the file is managed by Mercurial...
> 
> In order to let such systems work, we allow for a file:
> mercurial/modulepolicy to determine the policy.
> 
> A later patch will have setup.py write to this file.
> 
> diff --git a/mercurial/__init__.py b/mercurial/__init__.py
> --- a/mercurial/__init__.py
> +++ b/mercurial/__init__.py
> @@ -23,7 +23,15 @@
>  
>  # By default, require the C extensions for performance reasons.
>  if modulepolicy == '@' 'MODULELOADPOLICY' '@':
> -    modulepolicy = 'c'
> +    try:
> +        policyfile = os.path.join(os.path.dirname(__file__), 'modulepolicy')
> +        fp = open(policyfile, 'rb')
> +        r = fp.read()
> +        fp.close()
> +        if r:
> +            modulepolicy = r.split("\n")[0]
> +    except IOError:
> +        modulepolicy = 'c'

Looks like this isn't updated from V2.

http://patchwork.serpentine.com/patch/12675/

Patch

diff --git a/mercurial/__init__.py b/mercurial/__init__.py
--- a/mercurial/__init__.py
+++ b/mercurial/__init__.py
@@ -23,7 +23,15 @@ 
 
 # By default, require the C extensions for performance reasons.
 if modulepolicy == '@' 'MODULELOADPOLICY' '@':
-    modulepolicy = 'c'
+    try:
+        policyfile = os.path.join(os.path.dirname(__file__), 'modulepolicy')
+        fp = open(policyfile, 'rb')
+        r = fp.read()
+        fp.close()
+        if r:
+            modulepolicy = r.split("\n")[0]
+    except IOError:
+        modulepolicy = 'c'
 
 # PyPy doesn't load C extensions.
 #