[PATCH 5 of 7 v2] mercurial: check mercurial/modulepolicy for modulepolicy

Yuya Nishihara yuya at tcha.org
Fri Jan 15 07:08:00 CST 2016


On Mon, 11 Jan 2016 23:23:07 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless at mozdev.org>
> # Date 1452574998 0
> #      Tue Jan 12 05:03:18 2016 +0000
> # Node ID 21b17c69ea254cceefc474baabedd5a777278c8c
> # Parent  cffb330960bad95524d0d170fdc7aea009e5b01d
> 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'

Instead of adding two separate modulepolicy initialization schemes, can't it
be like __version__.py?

 1. setup.py generates mercurial/__modulepolicy__.py
 2. __init__.py try loading __modulepolicy__ and falls back to default


More information about the Mercurial-devel mailing list