Patchwork [1,of,7,V2] util: move getfstype() to the platform modules

login
register
mail settings
Submitter Matt Harbison
Date Dec. 31, 2017, 4:11 a.m.
Message ID <beede158ea8a740efb59.1514693468@Envy>
Download mbox | patch
Permalink /patch/26508/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 31, 2017, 4:11 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1514686023 18000
#      Sat Dec 30 21:07:03 2017 -0500
# Node ID beede158ea8a740efb59b46522f74490381a2086
# Parent  9b3f95d9783d99298232a6721a3e5fef5b277155
util: move getfstype() to the platform modules

This makes room for implementing on Windows using ctypes.

Patch

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -24,9 +24,12 @@ 
 from . import (
     encoding,
     error,
+    policy,
     pycompat,
 )
 
+osutil = policy.importmod(r'osutil')
+
 posixfile = open
 normpath = os.path.normpath
 samestat = os.path.samestat
@@ -302,6 +305,13 @@ 
     Returns None if the path is ok, or a UI string describing the problem.'''
     return None # on posix platforms, every path is ok
 
+def getfstype(dirpath):
+    '''Get the filesystem type name from a directory (best-effort)
+
+    Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc.
+    '''
+    return getattr(osutil, 'getfstype', lambda x: None)(dirpath)
+
 def setbinary(fd):
     pass
 
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -109,6 +109,7 @@ 
 expandglobs = platform.expandglobs
 explainexit = platform.explainexit
 findexe = platform.findexe
+getfstype = platform.getfstype
 gethgcmd = platform.gethgcmd
 getuser = platform.getuser
 getpid = os.getpid
@@ -1519,13 +1520,6 @@ 
 
     return ''.join(result)
 
-def getfstype(dirpath):
-    '''Get the filesystem type name from a directory (best-effort)
-
-    Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc.
-    '''
-    return getattr(osutil, 'getfstype', lambda x: None)(dirpath)
-
 def checknlink(testfile):
     '''check whether hardlink count reporting works properly'''
 
diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -226,6 +226,13 @@ 
 def checklink(path):
     return False
 
+def getfstype(dirpath):
+    '''Get the filesystem type name from a directory (best-effort)
+
+    Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc.
+    '''
+    return None
+
 def setbinary(fd):
     # When run without console, pipes may expose invalid
     # fileno(), usually set to -1.