Skip to content

Commit

Permalink
workspace: take old repo path as separate argument
Browse files Browse the repository at this point in the history
As I mentioned in recent patches, I'm about to remove
`ReadonlyRepo::repo_path()`.
  • Loading branch information
martinvonz committed Sep 7, 2024
1 parent 19f383f commit 0b6714a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cli/src/commands/workspace/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion lib/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,14 @@ impl Workspace {
pub fn init_workspace_with_existing_repo(
user_settings: &UserSettings,
workspace_root: &Path,
repo_path: &Path,
repo: &Arc<ReadonlyRepo>,
working_copy_factory: &dyn WorkingCopyFactory,
workspace_id: WorkspaceId,
) -> Result<(Self, Arc<ReadonlyRepo>), 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
Expand Down
1 change: 1 addition & 0 deletions lib/tests/test_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 0b6714a

Please sign in to comment.