sapling/eden/scm/edenscm/mercurial/fscap.py
Adam Simpkins ab3a7cb21f Move fb-mercurial sources into an eden/scm subdirectory.
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.
2019-11-13 16:04:48 -08:00

48 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}
_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,
"fuse.ntfs": {
SYMLINK: False,
HARDLINK: True,
EXECBIT: False,
ALWAYSCASESENSITIVE: False,
},
"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)