mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 22:37:37 +03:00
unicode: skip binary filenames coming from Eden
Summary: Mercurial can't handle these. Let's skip them instead of throwing an exception. Reviewed By: quark-zju Differential Revision: D20016007 fbshipit-source-id: dbf37b9e315d29bcfa1e12f51bc96ed543ff6d84
This commit is contained in:
parent
2fc5cacddc
commit
da9aa40c43
@ -195,6 +195,7 @@ class EdenHgTestCase(testcase.EdenTestCase, metaclass=abc.ABCMeta):
|
||||
msg: Optional[str] = None,
|
||||
op: Optional[str] = None,
|
||||
check_ignored: bool = True,
|
||||
rev: Optional[str] = None,
|
||||
) -> None:
|
||||
"""Asserts the output of `hg status` matches the expected state.
|
||||
|
||||
@ -204,7 +205,7 @@ class EdenHgTestCase(testcase.EdenTestCase, metaclass=abc.ABCMeta):
|
||||
|
||||
'C' is not currently supported.
|
||||
"""
|
||||
actual_status = self.repo.status(include_ignored=check_ignored)
|
||||
actual_status = self.repo.status(include_ignored=check_ignored, rev=rev)
|
||||
self.assertDictEqual(expected, actual_status, msg=msg)
|
||||
self.assert_unfinished_operation(op)
|
||||
|
||||
|
@ -132,7 +132,9 @@ class HgRepository(repobase.Repository):
|
||||
cwd=cwd,
|
||||
check=check,
|
||||
)
|
||||
return typing.cast(str, completed_process.stdout.decode(encoding))
|
||||
return typing.cast(
|
||||
str, completed_process.stdout.decode(encoding, errors="replace")
|
||||
)
|
||||
|
||||
def init(self, hgrc: Optional[configparser.ConfigParser] = None) -> None:
|
||||
"""
|
||||
@ -259,7 +261,9 @@ class HgRepository(repobase.Repository):
|
||||
json_data = json.loads(output)
|
||||
return typing.cast(List[Dict[str, Any]], json_data)
|
||||
|
||||
def status(self, include_ignored: bool = False) -> Dict[str, str]:
|
||||
def status(
|
||||
self, include_ignored: bool = False, rev: Optional[str] = None
|
||||
) -> Dict[str, str]:
|
||||
"""Returns the output of `hg status` as a dictionary of {path: status char}.
|
||||
|
||||
The status characters are the same as the ones documented by `hg help status`
|
||||
@ -267,6 +271,9 @@ class HgRepository(repobase.Repository):
|
||||
args = ["status", "--print0"]
|
||||
if include_ignored:
|
||||
args.append("-mardui")
|
||||
if rev is not None:
|
||||
args.append("--rev")
|
||||
args.append(rev)
|
||||
|
||||
output = self.hg(*args)
|
||||
status = {}
|
||||
|
@ -9,6 +9,7 @@ from typing import Callable, Iterable, Optional, Tuple
|
||||
|
||||
from . import filesystem, perftrace, pycompat, util
|
||||
from .EdenThriftClient import ScmFileStatus
|
||||
from .i18n import _
|
||||
from .pycompat import decodeutf8
|
||||
|
||||
|
||||
@ -30,6 +31,10 @@ class eden_filesystem(filesystem.physicalfilesystem):
|
||||
IGNORED = ScmFileStatus.IGNORED
|
||||
|
||||
for path, code in pycompat.iteritems(edenstatus):
|
||||
if not util.isvalidutf8(path):
|
||||
self.ui.warn(_("skipping invalid utf-8 filename: '%s'\n") % path)
|
||||
continue
|
||||
|
||||
path = decodeutf8(path)
|
||||
if not match(path):
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user