Patchwork [04,of,10] base85: switch to policy importer

login
register
mail settings
Submitter Yuya Nishihara
Date May 20, 2017, 8:41 a.m.
Message ID <318108db248cd6897210.1495269671@mimosa>
Download mbox | patch
Permalink /patch/20764/
State Accepted
Headers show

Comments

Yuya Nishihara - May 20, 2017, 8:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471057703 -32400
#      Sat Aug 13 12:08:23 2016 +0900
# Node ID 318108db248cd68972102fa6db645372fedc2b2c
# Parent  a62b1ca7c1f6ab7b8fa6597ff44393bd29285e56
base85: switch to policy importer

Patch

diff --git a/contrib/check-py3-compat.py b/contrib/check-py3-compat.py
--- a/contrib/check-py3-compat.py
+++ b/contrib/check-py3-compat.py
@@ -17,7 +17,6 @@  import traceback
 
 # Modules that have both Python and C implementations.
 _dualmodules = (
-    'base85.py',
     'bdiff.py',
     'diffhelpers.py',
     'mpatch.py',
diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -26,7 +26,6 @@  allowsymbolimports = (
 
 # Modules that have both Python and C implementations.
 _dualmodules = (
-    'base85.py',
     'bdiff.py',
     'diffhelpers.py',
     'mpatch.py',
diff --git a/contrib/wix/dist.wxs b/contrib/wix/dist.wxs
--- a/contrib/wix/dist.wxs
+++ b/contrib/wix/dist.wxs
@@ -12,7 +12,7 @@ 
       <Directory Id="libdir" Name="lib" FileSource="$(var.SourceDir)/lib">
         <Component Id="libOutput" Guid="$(var.lib.guid)" Win64='$(var.IsX64)'>
           <File Name="library.zip" KeyPath="yes" />
-          <File Name="mercurial.base85.pyd" />
+          <File Name="mercurial.cext.base85.pyd" />
           <File Name="mercurial.bdiff.pyd" />
           <File Name="mercurial.diffhelpers.pyd" />
           <File Name="mercurial.mpatch.pyd" />
diff --git a/mercurial/__init__.py b/mercurial/__init__.py
--- a/mercurial/__init__.py
+++ b/mercurial/__init__.py
@@ -23,7 +23,6 @@  modulepolicy = policy.policy
 # Modules that have both Python and C implementations. See also the
 # set of .py files under mercurial/pure/.
 _dualmodules = {
-    'mercurial.base85',
     'mercurial.bdiff',
     'mercurial.diffhelpers',
     'mercurial.mpatch',
diff --git a/mercurial/base85.c b/mercurial/cext/base85.c
rename from mercurial/base85.c
rename to mercurial/cext/base85.c
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -987,11 +987,11 @@  def debuginstall(ui, **opts):
         err = None
         try:
             from . import (
-                base85,
                 bdiff,
                 mpatch,
             )
             from .cext import (
+                base85,
                 osutil,
             )
             dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -42,7 +42,6 @@  import warnings
 import zlib
 
 from . import (
-    base85,
     encoding,
     error,
     i18n,
@@ -51,6 +50,7 @@  from . import (
     pycompat,
 )
 
+base85 = policy.importmod(r'base85')
 osutil = policy.importmod(r'osutil')
 
 b85decode = base85.b85decode
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -621,7 +621,7 @@  if sys.platform == 'darwin':
     osutil_ldflags += ['-framework', 'ApplicationServices']
 
 extmodules = [
-    Extension('mercurial.base85', ['mercurial/base85.c'],
+    Extension('mercurial.cext.base85', ['mercurial/cext/base85.c'],
               include_dirs=common_include_dirs,
               depends=common_depends),
     Extension('mercurial.bdiff', ['mercurial/bdiff.c',