Patchwork [03,of,10] osutil: switch to policy importer

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

Comments

Yuya Nishihara - May 20, 2017, 8:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1470969317 -32400
#      Fri Aug 12 11:35:17 2016 +0900
# Node ID a62b1ca7c1f6ab7b8fa6597ff44393bd29285e56
# Parent  76ed34b377b3f46c54d9c8e68f8f851a2cfc641c
osutil: switch to policy importer

"make clean" is recommended to test this change, though C API compatibility
should be preserved.

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
@@ -21,7 +21,6 @@  import traceback
     'bdiff.py',
     'diffhelpers.py',
     'mpatch.py',
-    'osutil.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
@@ -30,7 +30,6 @@  allowsymbolimports = (
     'bdiff.py',
     'diffhelpers.py',
     'mpatch.py',
-    'osutil.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
@@ -16,7 +16,7 @@ 
           <File Name="mercurial.bdiff.pyd" />
           <File Name="mercurial.diffhelpers.pyd" />
           <File Name="mercurial.mpatch.pyd" />
-          <File Name="mercurial.osutil.pyd" />
+          <File Name="mercurial.cext.osutil.pyd" />
           <File Name="mercurial.parsers.pyd" />
           <File Name="pyexpat.pyd" />
           <File Name="bz2.pyd" />
diff --git a/mercurial/__init__.py b/mercurial/__init__.py
--- a/mercurial/__init__.py
+++ b/mercurial/__init__.py
@@ -27,7 +27,6 @@  modulepolicy = policy.policy
     'mercurial.bdiff',
     'mercurial.diffhelpers',
     'mercurial.mpatch',
-    'mercurial.osutil',
     'mercurial.parsers',
 }
 
diff --git a/mercurial/osutil.c b/mercurial/cext/osutil.c
rename from mercurial/osutil.c
rename to mercurial/cext/osutil.c
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -990,6 +990,8 @@  def debuginstall(ui, **opts):
                 base85,
                 bdiff,
                 mpatch,
+            )
+            from .cext import (
                 osutil,
             )
             dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -13,7 +13,7 @@  import os
 import socket
 import stat as statmod
 
-from . import (
+from .. import (
     policy,
     pycompat,
 )
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -46,11 +46,13 @@  from . import (
     encoding,
     error,
     i18n,
-    osutil,
     parsers,
+    policy,
     pycompat,
 )
 
+osutil = policy.importmod(r'osutil')
+
 b85decode = base85.b85decode
 b85encode = base85.b85encode
 
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -17,7 +17,7 @@  import sys
 from .i18n import _
 from . import (
     encoding,
-    osutil,
+    policy,
     pycompat,
     win32,
 )
@@ -28,6 +28,8 @@  try:
 except ImportError:
     import winreg
 
+osutil = policy.importmod(r'osutil')
+
 executablepath = win32.executablepath
 getuser = win32.getuser
 hidewindow = win32.hidewindow
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -641,7 +641,7 @@  extmodules = [
                                     'mercurial/pathencode.c'],
               include_dirs=common_include_dirs,
               depends=common_depends),
-    Extension('mercurial.osutil', ['mercurial/osutil.c'],
+    Extension('mercurial.cext.osutil', ['mercurial/cext/osutil.c'],
               include_dirs=common_include_dirs,
               extra_compile_args=osutil_cflags,
               extra_link_args=osutil_ldflags,