mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 06:47:41 +03:00
f199e93924
Summary: On Windows, absolute paths are of multiple shape, with all of them having pros and cons. In particular, device paths (C:/) that EdenFS is using is limited to 260 characters. To bypass this limitation, UNC paths (\\?\) can be used, but no normalization is done automatically, specifically '/' aren't converted to '\'. Since UNC paths allow us to support long paths, and would also bring more safety to EdenFS by enforcing that all AbsolutePath are of the UNC form, let's use them. One of the other downside of UNC is that applications may not support them or may misbehave when passed to them. For this reason, EdenFS doesn't expose UNC paths in its Thrift API, changing the path to a device path, applications relying on Thrift are expected to re-UNC them. Reviewed By: chadaustin Differential Revision: D40818724 fbshipit-source-id: 260b8732df04bbffee6b2fe52f0ceda222d3941b
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
from typing import Dict
|
|
|
|
from facebook.eden.ttypes import GetScmStatusParams, ScmFileStatus
|
|
|
|
from .lib import testcase
|
|
|
|
|
|
@testcase.eden_repo_test()
|
|
class LongPathsTest(testcase.EdenRepoTest):
|
|
"""Verify that EdenFS behave properly when dealing with long paths."""
|
|
|
|
path: str = "a" * 100 + "/" + "b" * 100 + "/" + "c" * 100
|
|
file: str = path + "/" + "d" * 100
|
|
initial_commit: str = ""
|
|
|
|
def populate_repo(self) -> None:
|
|
self.repo.write_file(self.file, "Long path!\n")
|
|
self.initial_commit = self.repo.commit("a")
|
|
|
|
def test_read(self) -> None:
|
|
self.assertEqual(self.read_file(self.file), "Long path!\n")
|
|
|
|
def _eden_status(self, listIgnored: bool = False) -> Dict[bytes, ScmFileStatus]:
|
|
with self.eden.get_thrift_client_legacy() as client:
|
|
status = client.getScmStatusV2(
|
|
GetScmStatusParams(
|
|
mountPoint=self.mount.encode(),
|
|
commit=self.initial_commit.encode(),
|
|
listIgnored=listIgnored,
|
|
)
|
|
)
|
|
return status.status.entries
|
|
|
|
def test_materialize(self) -> None:
|
|
e = self.path + "/" + "e"
|
|
self.write_file(e, "Small file in long path!\n")
|
|
self.assertEqual(self._eden_status(), {e.encode(): ScmFileStatus.ADDED})
|