Patchwork [05,of,10] bdiff: switch to policy importer

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

Comments

Yuya Nishihara - May 20, 2017, 8:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471057970 -32400
#      Sat Aug 13 12:12:50 2016 +0900
# Node ID 0461104b08ec60e2b696c41d45e9d9677a956324
# Parent  318108db248cd68972102fa6db645372fedc2b2c
bdiff: 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 = (
-    'bdiff.py',
     'diffhelpers.py',
     'mpatch.py',
     'parsers.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 = (
-    'bdiff.py',
     'diffhelpers.py',
     'mpatch.py',
     'parsers.py',
diff --git a/contrib/wix/dist.wxs b/contrib/wix/dist.wxs
--- a/contrib/wix/dist.wxs
+++ b/contrib/wix/dist.wxs
@@ -13,7 +13,7 @@ 
         <Component Id="libOutput" Guid="$(var.lib.guid)" Win64='$(var.IsX64)'>
           <File Name="library.zip" KeyPath="yes" />
           <File Name="mercurial.cext.base85.pyd" />
-          <File Name="mercurial.bdiff.pyd" />
+          <File Name="mercurial.cext.bdiff.pyd" />
           <File Name="mercurial.diffhelpers.pyd" />
           <File Name="mercurial.mpatch.pyd" />
           <File Name="mercurial.cext.osutil.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.bdiff',
     'mercurial.diffhelpers',
     'mercurial.mpatch',
     'mercurial.parsers',
diff --git a/mercurial/bdiff_module.c b/mercurial/cext/bdiff.c
rename from mercurial/bdiff_module.c
rename to mercurial/cext/bdiff.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 (
-                bdiff,
                 mpatch,
             )
             from .cext import (
                 base85,
+                bdiff,
                 osutil,
             )
             dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -13,13 +13,15 @@  import zlib
 
 from .i18n import _
 from . import (
-    bdiff,
     error,
     mpatch,
+    policy,
     pycompat,
     util,
 )
 
+bdiff = policy.importmod(r'bdiff')
+
 blocks = bdiff.blocks
 fixws = bdiff.fixws
 patches = mpatch.patches
diff --git a/mercurial/pure/bdiff.py b/mercurial/pure/bdiff.py
--- a/mercurial/pure/bdiff.py
+++ b/mercurial/pure/bdiff.py
@@ -11,7 +11,7 @@  import difflib
 import re
 import struct
 
-from . import policy
+from .. import policy
 policynocffi = policy.policynocffi
 modulepolicy = policy.policy
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -624,8 +624,8 @@  extmodules = [
     Extension('mercurial.cext.base85', ['mercurial/cext/base85.c'],
               include_dirs=common_include_dirs,
               depends=common_depends),
-    Extension('mercurial.bdiff', ['mercurial/bdiff.c',
-                                  'mercurial/bdiff_module.c'],
+    Extension('mercurial.cext.bdiff', ['mercurial/bdiff.c',
+                                       'mercurial/cext/bdiff.c'],
               include_dirs=common_include_dirs,
               depends=common_depends + ['mercurial/bdiff.h']),
     Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'],