[PATCH 5 of 7 V2] util: add a function to show the mount point of the filesystem

Matt Harbison mharbison72 at gmail.com
Sat Dec 30 23:11:12 EST 2017


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1514606054 18000
#      Fri Dec 29 22:54:14 2017 -0500
# Node ID a71b3400aebc13b9beb0be6fe4c47d2b7bcf2808
# Parent  48cb8407217a0dce068d8bc8b3b88a9233d36fd3
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.

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -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)
 
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
+getfsmountpoint = platform.getfsmountpoint
 getfstype = platform.getfstype
 gethgcmd = platform.gethgcmd
 getuser = platform.getuser
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 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 win32.getvolumename(dirpath)
+
 def getfstype(dirpath):
     '''Get the filesystem type name from a directory (best-effort)
 


More information about the Mercurial-devel mailing list