sapling/eden/scm/edenscm/eden_dirstate_fs.py
Muir Manders 44343769f8 collapse edenscm.mercurial package into edenscm
Summary:
We want to rename away from "mercurial". Rather than rename the "mercurial" Python package, we opted to just collapse it into the parent "edenscm" package. This is also a step towards further organizing we want to do around the new project name.

To ease the transition wrt hotfixes, we now replace "edenscm.mercurial" with "mercurial" to fix imports within base64-python extensions.

Reviewed By: sggutier

Differential Revision: D38943169

fbshipit-source-id: 03fa18079c51e2f7fac05d65b127095da3ab7c99
2022-08-24 13:45:53 -07:00

53 lines
1.7 KiB
Python

# 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.
"""Eden implementation for the dirstate filesystem class."""
from typing import Callable, Iterable, Optional, Tuple
from . import filesystem, perftrace, pycompat, util
from .EdenThriftClient import ScmFileStatus
from .i18n import _
from .pycompat import decodeutf8
class eden_filesystem(filesystem.physicalfilesystem):
def pendingchanges(
self, match: "Optional[Callable[[str], bool]]" = None, listignored: bool = False
) -> "Iterable[Tuple[str, bool]]":
if match is None:
match = util.always
with perftrace.trace("Get EdenFS Status"):
perftrace.traceflag("status")
edenstatus = self.dirstate.eden_client.getStatus(
self.dirstate.p1(), list_ignored=listignored
)
MODIFIED = ScmFileStatus.MODIFIED
REMOVED = ScmFileStatus.REMOVED
ADDED = ScmFileStatus.ADDED
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
if code == MODIFIED or code == ADDED:
yield (path, True)
elif code == REMOVED:
yield (path, False)
elif code == IGNORED and listignored:
yield (path, True)
else:
raise RuntimeError(
"unexpected status code '%s' for '%s'" % (code, path)
)