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

timeless timeless at mozdev.org
Tue Jan 12 05:23:07 UTC 2016


# 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'
 
 # PyPy doesn't load C extensions.
 #



More information about the Mercurial-devel mailing list