workspace: avoid reloading stores when adding workspace

By calling `repo.loader()` on the existing repo, we reuse the same
commit store etc. That should make it easier to add out-of-tree
backends by removing one place we'd otherwise need to pass in a way of
creating a backend (now we reuse the instance that was already created
for the existing `repo`).
This commit is contained in:
Martin von Zweigbergk 2022-09-23 17:16:00 -07:00 committed by Martin von Zweigbergk
parent ea5aa0a96d
commit e41acc1c16

View file

@ -162,10 +162,9 @@ impl Workspace {
.write_all(repo_dir.to_str().unwrap().as_bytes())
.unwrap();
let repo_loader = RepoLoader::init(user_settings, &repo_dir);
let (working_copy, repo) =
init_working_copy(user_settings, repo, workspace_root, &jj_dir, workspace_id);
let workspace = Workspace::new(workspace_root, working_copy, repo_loader);
let workspace = Workspace::new(workspace_root, working_copy, repo.loader());
Ok((workspace, repo))
}