util: add a getfstype method
authorJun Wu <quark@fb.com>
Thu, 23 Mar 2017 11:58:45 -0700
changeset 31598 ae02cc1f5369
parent 31597 c5d924e5dfdb
child 31599 4a1bf30f5438
util: add a getfstype method The util version is a thin wrapper of the osutil version, which is not always available.
mercurial/util.py
--- a/mercurial/util.py	Mon Mar 20 00:19:33 2017 -0400
+++ b/mercurial/util.py	Thu Mar 23 11:58:45 2017 -0700
@@ -1367,6 +1367,13 @@
 
     return ''.join(result)
 
+def getfstype(dirpath):
+    '''Get the filesystem type name from a directory (best-effort)
+
+    Returns None if we are unsure, or errors like ENOENT, EPERM happen.
+    '''
+    return getattr(osutil, 'getfstype', lambda x: None)(dirpath)
+
 def checknlink(testfile):
     '''check whether hardlink count reporting works properly'''