From 0b6714a33cdc3a6f56a18ac84c7f2225855cee95 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 28 Aug 2024 07:58:34 -0700 Subject: [PATCH] workspace: take old repo path as separate argument As I mentioned in recent patches, I'm about to remove `ReadonlyRepo::repo_path()`. --- cli/src/commands/workspace/add.rs | 2 ++ lib/src/workspace.rs | 3 ++- lib/tests/test_workspace.rs | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/workspace/add.rs b/cli/src/commands/workspace/add.rs index b21b55e54..96d3d7572 100644 --- a/cli/src/commands/workspace/add.rs +++ b/cli/src/commands/workspace/add.rs @@ -107,9 +107,11 @@ pub fn cmd_workspace_add( } let working_copy_factory = command.get_working_copy_factory()?; + let repo_path = old_workspace_command.repo_path(); let (new_workspace, repo) = Workspace::init_workspace_with_existing_repo( command.settings(), &destination_path, + repo_path, repo, working_copy_factory, workspace_id, diff --git a/lib/src/workspace.rs b/lib/src/workspace.rs index 2f30883fd..8a6882403 100644 --- a/lib/src/workspace.rs +++ b/lib/src/workspace.rs @@ -340,13 +340,14 @@ impl Workspace { pub fn init_workspace_with_existing_repo( user_settings: &UserSettings, workspace_root: &Path, + repo_path: &Path, repo: &Arc, working_copy_factory: &dyn WorkingCopyFactory, workspace_id: WorkspaceId, ) -> Result<(Self, Arc), WorkspaceInitError> { let jj_dir = create_jj_dir(workspace_root)?; - let repo_dir = repo.repo_path().canonicalize().context(repo.repo_path())?; + let repo_dir = repo_path.canonicalize().context(repo_path)?; let repo_file_path = jj_dir.join("repo"); let mut repo_file = File::create(&repo_file_path).context(&repo_file_path)?; repo_file diff --git a/lib/tests/test_workspace.rs b/lib/tests/test_workspace.rs index 4be3d1b8c..fb3155a5f 100644 --- a/lib/tests/test_workspace.rs +++ b/lib/tests/test_workspace.rs @@ -54,6 +54,7 @@ fn test_init_additional_workspace() { let (ws2, repo) = Workspace::init_workspace_with_existing_repo( &settings, &ws2_root, + test_workspace.repo_path(), &test_workspace.repo, &*default_working_copy_factory(), ws2_id.clone(),