From da9aa40c433295f459e5613d306574211dd6c249 Mon Sep 17 00:00:00 2001 From: Durham Goode Date: Tue, 17 Mar 2020 09:11:11 -0700 Subject: [PATCH] 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 --- eden/integration/hg/lib/hg_extension_test_base.py | 3 ++- eden/integration/lib/hgrepo.py | 11 +++++++++-- eden/scm/edenscm/mercurial/eden_dirstate_fs.py | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/eden/integration/hg/lib/hg_extension_test_base.py b/eden/integration/hg/lib/hg_extension_test_base.py index b8a850c75a..83a32a4abb 100644 --- a/eden/integration/hg/lib/hg_extension_test_base.py +++ b/eden/integration/hg/lib/hg_extension_test_base.py @@ -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) diff --git a/eden/integration/lib/hgrepo.py b/eden/integration/lib/hgrepo.py index 7442d6c1fb..7efc4c8863 100644 --- a/eden/integration/lib/hgrepo.py +++ b/eden/integration/lib/hgrepo.py @@ -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 = {} diff --git a/eden/scm/edenscm/mercurial/eden_dirstate_fs.py b/eden/scm/edenscm/mercurial/eden_dirstate_fs.py index bdcae67edd..d7a91eefcc 100644 --- a/eden/scm/edenscm/mercurial/eden_dirstate_fs.py +++ b/eden/scm/edenscm/mercurial/eden_dirstate_fs.py @@ -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