From a27da7d8d56d74839c1c33dffccefa12ae7608dc Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 6 Nov 2022 16:11:40 -0800 Subject: [PATCH] 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`. --- lib/src/repo.rs | 6 ------ src/cli_util.rs | 4 ---- src/commands.rs | 12 ++++++++---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index e9220d2a2..9441aa778 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -206,12 +206,6 @@ impl ReadonlyRepo { }) } - pub fn reindex(&mut self) -> &Arc { - self.index_store.reinit(); - self.index.take(); - self.index() - } - pub fn store(&self) -> &Arc { &self.store } diff --git a/src/cli_util.rs b/src/cli_util.rs index e240c0034..e3d5ae17e 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -465,10 +465,6 @@ impl WorkspaceCommandHelper { &self.repo } - pub fn repo_mut(&mut self) -> &mut Arc { - &mut self.repo - } - pub fn working_copy(&self) -> &WorkingCopy { self.workspace.working_copy() } diff --git a/src/commands.rs b/src/commands.rs index 11c88a835..b5613128f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -3519,10 +3519,14 @@ fn cmd_debug( } } DebugCommands::ReIndex(_reindex_matches) => { - let mut workspace_command = command.workspace_helper(ui)?; - let mut_repo = Arc::get_mut(workspace_command.repo_mut()).unwrap(); - let index = mut_repo.reindex(); - writeln!(ui, "Finished indexing {:?} commits.", index.num_commits())?; + let workspace_command = command.workspace_helper(ui)?; + let repo = workspace_command.repo(); + let repo = repo.reload_at(repo.operation()); + writeln!( + ui, + "Finished indexing {:?} commits.", + repo.index().num_commits() + )?; } DebugCommands::Operation(operation_args) => { let workspace_command = command.workspace_helper(ui)?;