util: add a function to show the mount point of the filesystem
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 29 Dec 2017 22:54:14 -0500
changeset 35513 c4caf530b1c7
parent 35512 5cc1becd0493
child 35514 5880318624c9
util: add a function to show the mount point of the filesystem For now, this is Windows only, since Linux doesn't have the value in its statfs structure, and I don't have a BSD system to test with.
mercurial/posix.py
mercurial/util.py
mercurial/windows.py
--- a/mercurial/posix.py	Fri Dec 29 22:15:37 2017 -0500
+++ b/mercurial/posix.py	Fri Dec 29 22:54:14 2017 -0500
@@ -305,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 getfsmountpoint(dirpath):
+    '''Get the filesystem mount point from a directory (best-effort)
+
+    Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc.
+    '''
+    return getattr(osutil, 'getfsmountpoint', lambda x: None)(dirpath)
+
 def getfstype(dirpath):
     '''Get the filesystem type name from a directory (best-effort)
 
--- a/mercurial/util.py	Fri Dec 29 22:15:37 2017 -0500
+++ b/mercurial/util.py	Fri Dec 29 22:54:14 2017 -0500
@@ -109,6 +109,7 @@
 expandglobs = platform.expandglobs
 explainexit = platform.explainexit
 findexe = platform.findexe
+getfsmountpoint = platform.getfsmountpoint
 getfstype = platform.getfstype
 gethgcmd = platform.gethgcmd
 getuser = platform.getuser
--- a/mercurial/windows.py	Fri Dec 29 22:15:37 2017 -0500
+++ b/mercurial/windows.py	Fri Dec 29 22:54:14 2017 -0500
@@ -32,6 +32,7 @@
 osutil = policy.importmod(r'osutil')
 
 executablepath = win32.executablepath
+getfsmountpoint = win32.getvolumename
 getfstype = win32.getfstype
 getuser = win32.getuser
 hidewindow = win32.hidewindow