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 @@
-
+
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
@@ -1029,6 +1029,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,