mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
674e9c7900
Summary: In a strongly typed langage, using strings should be avoided whenever possible as they do not provide the safety guarantees that types provide. I took the liberty of removing all the filesystems that are not relevant for Mercurial for simplification reasons. If needs arise, we can always add a new FsType to the enum. Reviewed By: DurhamG Differential Revision: D20517138 fbshipit-source-id: 0a38b53c6a87f05f4b2d664038e10c4293de96ae
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
# Portions Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
# Copyright Matt Mackall <mpm@selenic.com> and others
|
|
#
|
|
# 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}
|
|
|
|
_EDENFS_POSIX_CAPS = {
|
|
SYMLINK: True,
|
|
HARDLINK: False,
|
|
EXECBIT: True,
|
|
ALWAYSCASESENSITIVE: True,
|
|
}
|
|
|
|
_FS_CAP_TABLE = {
|
|
"APFS": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
|
|
"Btrfs": _ALL_CAPS,
|
|
"EdenFS": _EDENFS_POSIX_CAPS,
|
|
"ext4": _ALL_CAPS,
|
|
"NTFS": {
|
|
SYMLINK: False,
|
|
HARDLINK: True,
|
|
EXECBIT: False,
|
|
ALWAYSCASESENSITIVE: False,
|
|
},
|
|
"HFS": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
|
|
"XFS": _ALL_CAPS,
|
|
"tmpfs": _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)
|