mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
64c6704fd6
Summary: On macOS, EdenFS can be configured to be case insensitive, and will soon be switching its default to be case insensitive. Mercurial however considers that EdenFS is always case sensistive on unix (linux, macOS), so let's change it on macOS so it manually checks if the working copy is. Long term, EdenFS on macOS will always be case insensitive, at which point this code will be changed again to indicate that and avoid the manual checks. Reviewed By: chadaustin Differential Revision: D26357816 fbshipit-source-id: 4022c097f2804da69cfcc176840683a6dca12ffd
64 lines
1.6 KiB
Python
64 lines
1.6 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"""
|
|
|
|
from . import pycompat
|
|
|
|
|
|
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: pycompat.islinux,
|
|
}
|
|
|
|
_EDENFS_WINDOWS_CAPS = {
|
|
SYMLINK: False,
|
|
HARDLINK: False,
|
|
EXECBIT: False,
|
|
ALWAYSCASESENSITIVE: False,
|
|
}
|
|
|
|
if pycompat.iswindows:
|
|
_EDENFS_CAPS = _EDENFS_WINDOWS_CAPS
|
|
else:
|
|
_EDENFS_CAPS = _EDENFS_POSIX_CAPS
|
|
|
|
_FS_CAP_TABLE = {
|
|
"APFS": {SYMLINK: True, HARDLINK: True, EXECBIT: True, ALWAYSCASESENSITIVE: False},
|
|
"Btrfs": _ALL_CAPS,
|
|
"EdenFS": _EDENFS_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)
|