repo: remove last mutating method from ReadonlyRepo

`ReadonlyRepo::reindex()` is only used in `jj debug reindex`, and it
can be implemented by creating a new instance instead of mutating
`ReadonlyRepo`.
This commit is contained in:
Martin von Zweigbergk 2022-11-06 16:11:40 -08:00 committed by Martin von Zweigbergk
parent cf3b6ee2c9
commit a27da7d8d5
3 changed files with 8 additions and 14 deletions

View File

@ -206,12 +206,6 @@ impl ReadonlyRepo {
}) })
} }
pub fn reindex(&mut self) -> &Arc<ReadonlyIndex> {
self.index_store.reinit();
self.index.take();
self.index()
}
pub fn store(&self) -> &Arc<Store> { pub fn store(&self) -> &Arc<Store> {
&self.store &self.store
} }

View File

@ -465,10 +465,6 @@ impl WorkspaceCommandHelper {
&self.repo &self.repo
} }
pub fn repo_mut(&mut self) -> &mut Arc<ReadonlyRepo> {
&mut self.repo
}
pub fn working_copy(&self) -> &WorkingCopy { pub fn working_copy(&self) -> &WorkingCopy {
self.workspace.working_copy() self.workspace.working_copy()
} }

View File

@ -3519,10 +3519,14 @@ fn cmd_debug(
} }
} }
DebugCommands::ReIndex(_reindex_matches) => { DebugCommands::ReIndex(_reindex_matches) => {
let mut workspace_command = command.workspace_helper(ui)?; let workspace_command = command.workspace_helper(ui)?;
let mut_repo = Arc::get_mut(workspace_command.repo_mut()).unwrap(); let repo = workspace_command.repo();
let index = mut_repo.reindex(); let repo = repo.reload_at(repo.operation());
writeln!(ui, "Finished indexing {:?} commits.", index.num_commits())?; writeln!(
ui,
"Finished indexing {:?} commits.",
repo.index().num_commits()
)?;
} }
DebugCommands::Operation(operation_args) => { DebugCommands::Operation(operation_args) => {
let workspace_command = command.workspace_helper(ui)?; let workspace_command = command.workspace_helper(ui)?;