[PATCH 2 of 7 V3] posix: add a getfstype method

Jun Wu quark at fb.com
Sun Mar 12 05:23:51 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1489305410 28800
#      Sat Mar 11 23:56:50 2017 -0800
# Node ID 9c4d023de5832618e06d9434968ef9af35d70986
# Parent  3fbaae1fa75a54a527d4f56963227561b65a8c28
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 9c4d023de583
posix: add a getfstype method

Use _getfstypetable() introduced by the last patch to read filesystem
information.

diff --git a/mercurial/posix.py b/mercurial/posix.py
--- a/mercurial/posix.py
+++ b/mercurial/posix.py
@@ -708,2 +708,15 @@ else:
     def _getfstypetable():
         return {}
+
+def getfstype(path):
+    """Given a path, return filesystem type or None (best effort)"""
+    nextpath = os.path.realpath(path)
+    table = _getfstypetable()
+    while True:
+        path = nextpath
+        fs = table.get(path, None)
+        if fs is not None:
+            return fs
+        nextpath = os.path.dirname(path)
+        if nextpath == path:
+            return None


More information about the Mercurial-devel mailing list