mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-16 00:56:23 +00:00
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.
This commit is contained in:
parent
e9952bcf76
commit
2282047d3b
1 changed files with 11 additions and 2 deletions
|
@ -268,13 +268,23 @@ jj init --git-repo=.",
|
||||||
WorkspaceLoadError::NonUnicodePath => user_error(err.to_string()),
|
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<WorkspaceCommandHelper, CommandError> {
|
||||||
let repo_loader = workspace.repo_loader();
|
let repo_loader = workspace.repo_loader();
|
||||||
let op_heads = resolve_op_for_load(
|
let op_heads = resolve_op_for_load(
|
||||||
repo_loader.op_store(),
|
repo_loader.op_store(),
|
||||||
repo_loader.op_heads_store(),
|
repo_loader.op_heads_store(),
|
||||||
&self.global_args.at_operation,
|
&self.global_args.at_operation,
|
||||||
)?;
|
)?;
|
||||||
let mut workspace_command = match op_heads {
|
let workspace_command = match op_heads {
|
||||||
OpHeads::Single(op) => {
|
OpHeads::Single(op) => {
|
||||||
let repo = repo_loader.load_at(&op);
|
let repo = repo_loader.load_at(&op);
|
||||||
self.for_loaded_repo(ui, workspace, repo)?
|
self.for_loaded_repo(ui, workspace, repo)?
|
||||||
|
@ -309,7 +319,6 @@ jj init --git-repo=.",
|
||||||
workspace_command
|
workspace_command
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
workspace_command.snapshot(ui)?;
|
|
||||||
Ok(workspace_command)
|
Ok(workspace_command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue