make eden clone respect backing store types

Summary:
# Context

If the user supplies a backing-repo path that points to an existing Eden repo, then clone will try to copy that existing repo's CheckoutConfig. This works in most cases, but it will override user supplied options in other cases. One such case was when the user supplied a --backing-repo option. This option was entirely ignored in favor of whatever value was contained in the existing repo's checkout config.

# Solution

We should teach clone to respect the user-supplied option or default to "hg" if no option is supplied.

# This diff

Adds a check to ensure the backing store types match. If not, it replace the backing store field with the option supplied by the user (or "hg" by default)

Reviewed By: genevievehelsel

Differential Revision: D56593400

fbshipit-source-id: 608e26a6556cd6f0df6ed06a963ea1bfbfc0ea77
This commit is contained in:
Michael Cuevas 2024-04-30 20:19:12 -07:00 committed by Facebook GitHub Bot
parent c7e2c8471d
commit bbb54381de

View File

@ -816,7 +816,8 @@ class CloneCmd(Subcmd):
help=(
"Clone the path with a specified Backing Store implementation. "
"Currently only supports 'filteredhg' (all), 'recas' (Linux), "
"and 'http' (Linux)."
"and 'http' (Linux). Takes precedent over the inferred backing"
"store type from the existing repository we're cloning from."
),
)
@ -1075,6 +1076,14 @@ is case-sensitive. This is not recommended and is intended only for testing."""
# Check to see if repo_arg points to an existing EdenFS mount
checkout_config = instance.get_checkout_config_for_path(repo_arg)
if checkout_config is not None:
if backing_store_type is not None:
# If the user specified a backing store type, make sure it takes
# priority over the existing checkout config.
if backing_store_type != checkout_config.scm_type:
checkout_config = checkout_config._replace(
scm_type=backing_store_type
)
repo = util.get_repo(str(checkout_config.backing_repo), backing_store_type)
if repo is None:
raise RepoError(