def METHOD_NAME(
    repo: "Repo",
    rev: str,
    repo_root_parts: Tuple[str, ...],
    cwd_parts: Tuple[str, ...],
):
    from dvc.fs import GitFileSystem, LocalFileSystem
    if rev == "workspace":
        logger.trace("switching fs to workspace")  # type: ignore[attr-defined]
        repo.fs = LocalFileSystem(url=repo.root_dir)
        return
    logger.trace("switching fs to revision %s", rev[:7])  # type: ignore[attr-defined]
    assert isinstance(repo.scm, Git)
    fs = GitFileSystem(scm=repo.scm, rev=rev)
    root_dir = repo.fs.path.join("/", *repo_root_parts)
    if not fs.exists(root_dir):
        raise NotDvcRepoError(f"Commit '{rev[:7]}' does not contain a DVC repo")
    repo.fs = fs
    repo.root_dir = root_dir
    repo.dvc_dir = fs.path.join(root_dir, repo.DVC_DIR)
    repo._reset()  # pylint: disable=protected-access
    if cwd_parts:
        cwd = repo.fs.path.join("/", *cwd_parts)
        repo.fs.path.chdir(cwd)