From bbb54381de5e1486d2aa36d376b4b905014e2885 Mon Sep 17 00:00:00 2001 From: Michael Cuevas Date: Tue, 30 Apr 2024 20:19:12 -0700 Subject: [PATCH] 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 --- eden/fs/cli/main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/eden/fs/cli/main.py b/eden/fs/cli/main.py index 3c9a97afef..288d1f6595 100644 --- a/eden/fs/cli/main.py +++ b/eden/fs/cli/main.py @@ -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(