changeset 31593:ae02cc1f5369

util: add a getfstype method The util version is a thin wrapper of the osutil version, which is not always available.
author Jun Wu <quark@fb.com>
date Thu, 23 Mar 2017 11:58:45 -0700
parents c5d924e5dfdb
children 4a1bf30f5438
files mercurial/util.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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'''