From 2282047d3b52c755a808c9525074d1ec525a4db2 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sun, 9 Oct 2022 10:01:05 -0700 Subject: [PATCH] cli_util: extract a function for creating a helper given a workspace The code for creating a `WorkspaceCommandHelper` for a given `Workspace` is a well-separated part of the large `workspace_helper()`, so lets extract it to a function. --- src/cli_util.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cli_util.rs b/src/cli_util.rs index 14dee2610..aa7f98073 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -268,13 +268,23 @@ jj init --git-repo=.", WorkspaceLoadError::NonUnicodePath => user_error(err.to_string()), } })?; + let mut workspace_command = self.resolve_operation(ui, workspace)?; + workspace_command.snapshot(ui)?; + Ok(workspace_command) + } + + fn resolve_operation( + &self, + ui: &mut Ui, + workspace: Workspace, + ) -> Result { let repo_loader = workspace.repo_loader(); let op_heads = resolve_op_for_load( repo_loader.op_store(), repo_loader.op_heads_store(), &self.global_args.at_operation, )?; - let mut workspace_command = match op_heads { + let workspace_command = match op_heads { OpHeads::Single(op) => { let repo = repo_loader.load_at(&op); self.for_loaded_repo(ui, workspace, repo)? @@ -309,7 +319,6 @@ jj init --git-repo=.", workspace_command } }; - workspace_command.snapshot(ui)?; Ok(workspace_command) }