forked from mirrors/jj
cli: move call to snapshot()
out of for_loaded_repo()
We don't always want to do the snapshotting etc. right away, so let's have the callers decide when to do it. This is just a refactoring; I'll change the behavior slightly in separate commits.
This commit is contained in:
parent
94a91d9864
commit
34c24ae035
2 changed files with 9 additions and 6 deletions
|
@ -247,6 +247,7 @@ jj init --git-repo=.";
|
||||||
let base_repo = repo_loader.load_at(&op_heads[0]);
|
let base_repo = repo_loader.load_at(&op_heads[0]);
|
||||||
// TODO: It may be helpful to print each operation we're merging here
|
// TODO: It may be helpful to print each operation we're merging here
|
||||||
let mut workspace_command = self.for_loaded_repo(ui, workspace, base_repo)?;
|
let mut workspace_command = self.for_loaded_repo(ui, workspace, base_repo)?;
|
||||||
|
workspace_command.snapshot(ui)?;
|
||||||
let mut tx = workspace_command.start_transaction("resolve concurrent operations");
|
let mut tx = workspace_command.start_transaction("resolve concurrent operations");
|
||||||
for other_op_head in op_heads.into_iter().skip(1) {
|
for other_op_head in op_heads.into_iter().skip(1) {
|
||||||
tx.merge_operation(other_op_head);
|
tx.merge_operation(other_op_head);
|
||||||
|
@ -266,24 +267,24 @@ jj init --git-repo=.";
|
||||||
return Ok(workspace_command);
|
return Ok(workspace_command);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.for_loaded_repo(ui, workspace, repo)
|
let mut workspace_command = self.for_loaded_repo(ui, workspace, repo)?;
|
||||||
|
workspace_command.snapshot(ui)?;
|
||||||
|
Ok(workspace_command)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_loaded_repo(
|
pub fn for_loaded_repo(
|
||||||
&self,
|
&self,
|
||||||
ui: &mut Ui,
|
ui: &Ui,
|
||||||
workspace: Workspace,
|
workspace: Workspace,
|
||||||
repo: Arc<ReadonlyRepo>,
|
repo: Arc<ReadonlyRepo>,
|
||||||
) -> Result<WorkspaceCommandHelper, CommandError> {
|
) -> Result<WorkspaceCommandHelper, CommandError> {
|
||||||
let mut helper = WorkspaceCommandHelper::new(
|
WorkspaceCommandHelper::new(
|
||||||
ui,
|
ui,
|
||||||
workspace,
|
workspace,
|
||||||
self.string_args.clone(),
|
self.string_args.clone(),
|
||||||
&self.global_args,
|
&self.global_args,
|
||||||
repo,
|
repo,
|
||||||
)?;
|
)
|
||||||
helper.snapshot(ui)?;
|
|
||||||
Ok(helper)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1077,6 +1077,7 @@ fn cmd_init(ui: &mut Ui, command: &CommandHelper, args: &InitArgs) -> Result<(),
|
||||||
Workspace::init_external_git(ui.settings(), &wc_path, &git_store_path)?;
|
Workspace::init_external_git(ui.settings(), &wc_path, &git_store_path)?;
|
||||||
let git_repo = repo.store().git_repo().unwrap();
|
let git_repo = repo.store().git_repo().unwrap();
|
||||||
let mut workspace_command = command.for_loaded_repo(ui, workspace, repo)?;
|
let mut workspace_command = command.for_loaded_repo(ui, workspace, repo)?;
|
||||||
|
workspace_command.snapshot(ui)?;
|
||||||
if workspace_command.working_copy_shared_with_git() {
|
if workspace_command.working_copy_shared_with_git() {
|
||||||
add_to_git_exclude(ui, &git_repo)?;
|
add_to_git_exclude(ui, &git_repo)?;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4105,6 +4106,7 @@ fn do_git_clone(
|
||||||
let git_repo = get_git_repo(repo.store())?;
|
let git_repo = get_git_repo(repo.store())?;
|
||||||
writeln!(ui, r#"Fetching into new repo in "{}""#, wc_path.display())?;
|
writeln!(ui, r#"Fetching into new repo in "{}""#, wc_path.display())?;
|
||||||
let mut workspace_command = command.for_loaded_repo(ui, workspace, repo)?;
|
let mut workspace_command = command.for_loaded_repo(ui, workspace, repo)?;
|
||||||
|
workspace_command.snapshot(ui)?;
|
||||||
let remote_name = "origin";
|
let remote_name = "origin";
|
||||||
git_repo.remote(remote_name, source).unwrap();
|
git_repo.remote(remote_name, source).unwrap();
|
||||||
let mut fetch_tx = workspace_command.start_transaction("fetch from git remote into empty repo");
|
let mut fetch_tx = workspace_command.start_transaction("fetch from git remote into empty repo");
|
||||||
|
|
Loading…
Reference in a new issue