sapling/mercurial/fscap.py
Mark Thomas 049a0485ad pathutil: don't check for case sensitivity on always case-sensitive filesystems
Summary:
When creating a VFS, Mercurial attempts to check if it is case sensitive by
stating the root of the VFS with differently cased names.  If the root of the
VFS is a directory on an autofs mount, this check can be slow.  Don't bother
checking if the VFS root has a filesystem type that we know is always case
sensitive.

Reviewed By: quark-zju

Differential Revision: D9993177

fbshipit-source-id: 4395b16f5f7b32218836422b44dae953dfb8c52b
2018-09-24 14:23:03 -07:00

37 lines
1.1 KiB
Python

# Copyright Facebook, Inc. 2018
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
"""capabilities of well-known filesystems"""
SYMLINK = "symlink"
HARDLINK = "hardlink"
EXECBIT = "execbit"
ALWAYSCASESENSITIVE = "alwayscasesensitive"
_ALL_CAPS = {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: True}
_FS_CAP_TABLE = {
"apfs": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
"btrfs": _ALL_CAPS,
"eden": {SYMLINK: True, HARDLINK: False, EXECBIT: True, ALWAYSCASESENSITIVE: True},
"ext2": _ALL_CAPS,
"ext3": _ALL_CAPS,
"ext4": _ALL_CAPS,
"hfs": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
"jfs": _ALL_CAPS,
"reiserfs": _ALL_CAPS,
"tmpfs": _ALL_CAPS,
"ufs": _ALL_CAPS,
"xfs": _ALL_CAPS,
"zfs": _ALL_CAPS,
}
def getfscap(fstype, cap):
"""Test if a filesystem has specified capability.
Return True if it has, False if it doesn't, or None if unsure.
"""
return _FS_CAP_TABLE.get(fstype, {}).get(cap)