Patchwork [06,of,10] diffhelpers: switch to policy importer

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

Comments

Yuya Nishihara - May 20, 2017, 8:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1471058149 -32400
#      Sat Aug 13 12:15:49 2016 +0900
# Node ID a81738a0469135083ffaec9b5cbd4a7a7f77e838
# Parent  0461104b08ec60e2b696c41d45e9d9677a956324
diffhelpers: 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 = (
-    '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 = (
-    '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
@@ -14,7 +14,7 @@ 
           <File Name="library.zip" KeyPath="yes" />
           <File Name="mercurial.cext.base85.pyd" />
           <File Name="mercurial.cext.bdiff.pyd" />
-          <File Name="mercurial.diffhelpers.pyd" />
+          <File Name="mercurial.cext.diffhelpers.pyd" />
           <File Name="mercurial.mpatch.pyd" />
           <File Name="mercurial.cext.osutil.pyd" />
           <File Name="mercurial.parsers.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.diffhelpers',
     'mercurial.mpatch',
     'mercurial.parsers',
 }
diff --git a/mercurial/diffhelpers.c b/mercurial/cext/diffhelpers.c
rename from mercurial/diffhelpers.c
rename to mercurial/cext/diffhelpers.c
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -27,18 +27,20 @@  from .node import (
 )
 from . import (
     copies,
-    diffhelpers,
     encoding,
     error,
     mail,
     mdiff,
     pathutil,
+    policy,
     pycompat,
     scmutil,
     similar,
     util,
     vfs as vfsmod,
 )
+
+diffhelpers = policy.importmod(r'diffhelpers')
 stringio = util.stringio
 
 gitre = re.compile(br'diff --git a/(.*) b/(.*)')
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -628,7 +628,7 @@  extmodules = [
                                        'mercurial/cext/bdiff.c'],
               include_dirs=common_include_dirs,
               depends=common_depends + ['mercurial/bdiff.h']),
-    Extension('mercurial.diffhelpers', ['mercurial/diffhelpers.c'],
+    Extension('mercurial.cext.diffhelpers', ['mercurial/cext/diffhelpers.c'],
               include_dirs=common_include_dirs,
               depends=common_depends),
     Extension('mercurial.mpatch', ['mercurial/mpatch.c',