remove some internal uses of the term 'client'

Summary:
Our use of the term "client" to refer to a checkout is
deprecated. Rename some internal functions that use the term client.

Reviewed By: simpkins

Differential Revision: D21395159

fbshipit-source-id: fa96ba593f53b493e5ae816fa686f333a132c232
This commit is contained in:
Chad Austin 2020-05-07 22:06:36 -07:00 committed by Facebook GitHub Bot
parent eb939cff57
commit c4db2f39a9
5 changed files with 17 additions and 33 deletions

View File

@ -344,23 +344,20 @@ class EdenInstance:
"""Return the paths of the set mount points stored in config.json"""
return [str(path) for path in self._get_directory_map().keys()]
def get_all_client_config_info(self) -> Dict[str, collections.OrderedDict]:
info = {}
for path in self.get_mount_paths():
info[path] = self.get_client_info(path)
return info
def get_thrift_client(self) -> eden.thrift.EdenClient:
return eden.thrift.create_thrift_client(str(self._config_dir))
def get_client_info(self, path: Union[Path, str]) -> collections.OrderedDict:
def get_checkout_info(self, path: Union[Path, str]) -> collections.OrderedDict:
"""
Given a path to a checkout, return a dictionary containing diagnostic
information about it.
"""
path = Path(path).resolve(strict=False)
client_dir = self._get_client_dir_for_mount_point(path)
checkout = EdenCheckout(self, path, client_dir)
return self.get_client_info_from_checkout(checkout)
return self.get_checkout_info_from_checkout(checkout)
def get_client_info_from_checkout(
def get_checkout_info_from_checkout(
self, checkout: "EdenCheckout"
) -> collections.OrderedDict:
checkout_config = checkout.get_config()
@ -370,7 +367,7 @@ class EdenInstance:
("mount", str(checkout.path)),
("scm_type", checkout_config.scm_type),
("snapshot", snapshot),
("client-dir", str(checkout.state_dir)),
("state_dir", str(checkout.state_dir)),
]
)

View File

@ -209,17 +209,6 @@ class FakeEdenInstance:
def check_health(self) -> HealthStatus:
return HealthStatus(self._status, pid=None, detail="")
def get_client_info(self, mount_path: str) -> collections.OrderedDict:
checkout = self._checkouts_by_path[mount_path]
return collections.OrderedDict(
[
("mount", mount_path),
("scm_type", checkout.config.scm_type),
("snapshot", checkout.snapshot),
("client-dir", checkout.state_dir),
]
)
def get_server_build_info(self) -> Dict[str, str]:
return dict(self._build_info)

View File

@ -102,7 +102,7 @@ class InfoCmd(Subcmd):
def run(self, args: argparse.Namespace) -> int:
instance, checkout, _rel_path = require_checkout(args, args.client)
info = instance.get_client_info_from_checkout(checkout)
info = instance.get_checkout_info_from_checkout(checkout)
json.dump(info, sys.stdout, indent=2)
sys.stdout.write("\n")
return 0
@ -271,9 +271,8 @@ Legacy bind mount dirs listed above are unused and can be removed!
self.underlined(f"Mount: {mount}")
instance, checkout, _rel_path = require_checkout(args, mount)
info = instance.get_client_info_from_checkout(checkout)
client_dir = info["client-dir"]
client_dir = checkout.state_dir
overlay_dir = os.path.join(client_dir, "local")
self.usage_for_dir("Materialized files", overlay_dir)
@ -281,7 +280,7 @@ Legacy bind mount dirs listed above are unused and can be removed!
if self.isatty:
print(f"Computing usage of ignored files...", end="", flush=True)
scm_status = client.getScmStatus(
bytes(checkout.path), True, info["snapshot"]
bytes(checkout.path), True, checkout.get_snapshot().encode()
)
ignored_usage = 0
buckd_usage = 0

View File

@ -60,12 +60,11 @@ def print_diagnostic_info(instance: EdenInstance, out: IO[bytes]) -> None:
out.write(b"\nList of mount points:\n")
mountpoint_paths = []
for key in sorted(instance.get_mount_paths()):
key_bytes = key.encode()
out.write(key_bytes)
mountpoint_paths.append(key_bytes)
for key, val in instance.get_all_client_config_info().items():
out.write(b"\nMount point info for path %s:\n" % key.encode())
for k, v in val.items():
out.write(key.encode() + b"\n")
mountpoint_paths.append(key)
for checkout_path in mountpoint_paths:
out.write(b"\nMount point info for path %s:\n" % checkout_path.encode())
for k, v in instance.get_checkout_info(checkout_path).items():
out.write("{:>10} : {}\n".format(k, v).encode())
if health_status.is_healthy():
with io.StringIO() as stats_stream:

View File

@ -29,7 +29,7 @@ class InfoTest(testcase.EdenRepoTest):
)
self.assertEqual(
{
"client-dir": client_dir,
"state_dir": client_dir,
"scm_type": self.repo.get_type(),
"mount": self.mount,
"snapshot": self.repo.get_head_hash(),