diff --git a/cli/examples/custom-command/main.rs b/cli/examples/custom-command/main.rs index ba07c8ea52a..b8b2dc2eeea 100644 --- a/cli/examples/custom-command/main.rs +++ b/cli/examples/custom-command/main.rs @@ -49,7 +49,7 @@ async fn run_custom_command( .set_description("Frobnicated!") .write() .await?; - tx.finish(ui, "frobnicate")?; + tx.finish(ui, "frobnicate").await?; writeln!( ui.status(), "Frobnicated revision: {}", diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 40bacefd1be..808af887d74 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -454,7 +454,8 @@ impl CommandHelper { ) -> Result<(WorkspaceCommandHelper, SnapshotStats), CommandError> { let mut workspace_command = self.workspace_helper_no_snapshot(ui)?; - let (workspace_command, stats) = match workspace_command.maybe_snapshot_impl(ui) { + let (workspace_command, stats) = match workspace_command.maybe_snapshot_impl(ui).block_on() + { Ok(stats) => (workspace_command, stats), Err(SnapshotWorkingCopyError::Command(err)) => return Err(err), Err(SnapshotWorkingCopyError::StaleWorkingCopy(err)) => { @@ -467,7 +468,7 @@ impl CommandHelper { // auto-update-stale, so let's do that now. We need to do it up here, not at a // lower level (e.g. inside snapshot_working_copy()) to avoid recursive locking // of the working copy. - self.recover_stale_working_copy(ui)? + self.recover_stale_working_copy(ui).block_on()? } }; @@ -559,16 +560,16 @@ impl CommandHelper { /// Note that unless you have a good reason not to do so, you should always /// call [`print_snapshot_stats`] with the [`SnapshotStats`] returned by /// this function to present possible untracked files to the user. - pub fn recover_stale_working_copy( + pub async fn recover_stale_working_copy( &self, ui: &Ui, ) -> Result<(WorkspaceCommandHelper, SnapshotStats), CommandError> { let workspace = self.load_workspace()?; let op_id = workspace.working_copy().operation_id(); - match workspace.repo_loader().load_operation(op_id).block_on() { + match workspace.repo_loader().load_operation(op_id).await { Ok(op) => { - let repo = workspace.repo_loader().load_at(&op).block_on()?; + let repo = workspace.repo_loader().load_at(&op).await?; let mut workspace_command = self.for_workable_repo(ui, workspace, repo)?; workspace_command.check_working_copy_writable()?; @@ -578,12 +579,12 @@ impl CommandHelper { // fine if we picked the new wc_commit_id. let stale_stats = workspace_command .snapshot_working_copy(ui) - .block_on() + .await .map_err(|err| err.into_command_error())?; let wc_commit_id = workspace_command.get_wc_commit_id().unwrap(); let repo = workspace_command.repo().clone(); - let stale_wc_commit = repo.store().get_commit(wc_commit_id)?; + let stale_wc_commit = repo.store().get_commit_async(wc_commit_id).await?; let mut workspace_command = self.workspace_helper_no_snapshot(ui)?; @@ -595,7 +596,7 @@ impl CommandHelper { &desired_wc_commit, &repo, ) - .block_on()? + .await? { WorkingCopyFreshness::Fresh | WorkingCopyFreshness::Updated(_) => { drop(locked_ws); @@ -611,7 +612,8 @@ impl CommandHelper { repo.op_id().clone(), &stale_wc_commit, &desired_wc_commit, - )?; + ) + .await?; workspace_command.print_updated_working_copy_stats( ui, Some(&stale_wc_commit), @@ -632,6 +634,7 @@ impl CommandHelper { // should be no data loss at least. let fresh_stats = workspace_command .maybe_snapshot_impl(ui) + .await .map_err(|err| err.into_command_error())?; let merged_stats = { let SnapshotStats { @@ -650,7 +653,9 @@ impl CommandHelper { )?; let mut workspace_command = self.workspace_helper_no_snapshot(ui)?; - let stats = workspace_command.create_and_check_out_recovery_commit(ui)?; + let stats = workspace_command + .create_and_check_out_recovery_commit(ui) + .await?; Ok((workspace_command, stats)) } Err(e) => Err(e.into()), @@ -1176,7 +1181,10 @@ impl WorkspaceCommandHelper { /// call [`print_snapshot_stats`] with the [`SnapshotStats`] returned by /// this function to present possible untracked files to the user. #[instrument(skip_all)] - fn maybe_snapshot_impl(&mut self, ui: &Ui) -> Result { + async fn maybe_snapshot_impl( + &mut self, + ui: &Ui, + ) -> Result { if !self.may_update_working_copy { return Ok(SnapshotStats::default()); } @@ -1196,7 +1204,7 @@ impl WorkspaceCommandHelper { let op_heads_store = repo.loader().op_heads_store(); let op_heads = op_heads_store .get_op_heads() - .block_on() + .await .map_err(snapshot_command_error)?; if std::slice::from_ref(repo.op_id()) != op_heads { let op = self @@ -1207,7 +1215,7 @@ impl WorkspaceCommandHelper { let current_repo = repo .loader() .load_at(&op) - .block_on() + .await .map_err(snapshot_command_error)?; self.user_repo = ReadonlyUserRepo::new(current_repo); } @@ -1216,18 +1224,20 @@ impl WorkspaceCommandHelper { #[cfg(feature = "git")] if self.working_copy_shared_with_git { self.import_git_head(ui, &git_import_export_lock) + .await .map_err(snapshot_command_error)?; } // Because the Git refs (except HEAD) aren't imported yet, the ref // pointing to the new working-copy commit might not be exported. // In that situation, the ref would be conflicted anyway, so export // failure is okay. - let stats = self.snapshot_working_copy(ui).block_on()?; + let stats = self.snapshot_working_copy(ui).await?; // import_git_refs() can rebase the working-copy commit. #[cfg(feature = "git")] if self.working_copy_shared_with_git { self.import_git_refs(ui, &git_import_export_lock) + .await .map_err(snapshot_command_error)?; } Ok(stats) @@ -1238,10 +1248,11 @@ impl WorkspaceCommandHelper { /// /// Returns whether a snapshot was taken. #[instrument(skip_all)] - pub fn maybe_snapshot(&mut self, ui: &Ui) -> Result { + pub async fn maybe_snapshot(&mut self, ui: &Ui) -> Result { let op_id_before = self.repo().op_id().clone(); let stats = self .maybe_snapshot_impl(ui) + .await .map_err(|err| err.into_command_error())?; print_snapshot_stats(ui, &stats, self.env().path_converter())?; let op_id_after = self.repo().op_id(); @@ -1256,14 +1267,14 @@ impl WorkspaceCommandHelper { /// working-copy contents won't be updated. #[cfg(feature = "git")] #[instrument(skip_all)] - fn import_git_head( + async fn import_git_head( &mut self, ui: &Ui, git_import_export_lock: &GitImportExportLock, ) -> Result<(), CommandError> { assert!(self.may_update_working_copy); let mut tx = self.start_transaction(); - jj_lib::git::import_head(tx.repo_mut()).block_on()?; + jj_lib::git::import_head(tx.repo_mut()).await?; if !tx.repo().has_changes() { return Ok(()); } @@ -1277,17 +1288,17 @@ impl WorkspaceCommandHelper { let wc_commit = tx .repo_mut() .check_out(workspace_name, &new_git_head_commit) - .block_on()?; + .await?; let mut locked_ws = self.workspace.start_working_copy_mutation()?; // The working copy was presumably updated by the git command that updated // HEAD, so we just need to reset our working copy // state to it without updating working copy files. - locked_ws.locked_wc().reset(&wc_commit).block_on()?; - tx.repo_mut().rebase_descendants().block_on()?; - self.user_repo = ReadonlyUserRepo::new(tx.commit("import git head").block_on()?); + locked_ws.locked_wc().reset(&wc_commit).await?; + tx.repo_mut().rebase_descendants().await?; + self.user_repo = ReadonlyUserRepo::new(tx.commit("import git head").await?); locked_ws .finish(self.user_repo.repo.op_id().clone()) - .block_on()?; + .await?; if old_git_head.is_present() { writeln!( ui.status(), @@ -1298,7 +1309,8 @@ impl WorkspaceCommandHelper { } } else { // Unlikely, but the HEAD ref got deleted by git? - self.finish_transaction(ui, tx, "import git head", git_import_export_lock)?; + self.finish_transaction(ui, tx, "import git head", git_import_export_lock) + .await?; } Ok(()) } @@ -1313,7 +1325,7 @@ impl WorkspaceCommandHelper { /// the working copy parent if the repository is colocated. #[cfg(feature = "git")] #[instrument(skip_all)] - fn import_git_refs( + async fn import_git_refs( &mut self, ui: &Ui, git_import_export_lock: &GitImportExportLock, @@ -1324,7 +1336,7 @@ impl WorkspaceCommandHelper { let import_options = crate::git_util::load_git_import_options(ui, &git_settings, &remote_settings)?; let mut tx = self.start_transaction(); - let stats = git::import_refs(tx.repo_mut(), &import_options).block_on()?; + let stats = git::import_refs(tx.repo_mut(), &import_options).await?; crate::git_util::print_git_import_stats_summary(ui, &stats)?; if !tx.repo().has_changes() { return Ok(()); @@ -1332,14 +1344,15 @@ impl WorkspaceCommandHelper { let mut tx = tx.into_inner(); // Rebase here to show slightly different status message. - let num_rebased = tx.repo_mut().rebase_descendants().block_on()?; + let num_rebased = tx.repo_mut().rebase_descendants().await?; if num_rebased > 0 { writeln!( ui.status(), "Rebased {num_rebased} descendant commits off of commits rewritten from git" )?; } - self.finish_transaction(ui, tx, "import git refs", git_import_export_lock)?; + self.finish_transaction(ui, tx, "import git refs", git_import_export_lock) + .await?; writeln!( ui.status(), "Done importing changes from the underlying Git repo." @@ -1394,7 +1407,7 @@ impl WorkspaceCommandHelper { Ok((locked_ws, wc_commit)) } - fn create_and_check_out_recovery_commit( + async fn create_and_check_out_recovery_commit( &mut self, ui: &Ui, ) -> Result { @@ -1415,17 +1428,18 @@ what the parent commits are supposed to be. That means that the diff compared to the current parents may contain changes from multiple commits. ", ) - .block_on()?; + .await?; writeln!( ui.status(), "Created and checked out recovery commit {}", short_commit_hash(new_commit.id()) )?; - locked_ws.finish(repo.op_id().clone()).block_on()?; + locked_ws.finish(repo.op_id().clone()).await?; self.user_repo = ReadonlyUserRepo::new(repo); self.maybe_snapshot_impl(ui) + .await .map_err(|err| err.into_command_error()) } @@ -1880,16 +1894,16 @@ to the current parents may contain changes from multiple commits. self.commit_summary_template().format(commit, formatter) } - pub fn check_rewritable<'a>( + pub async fn check_rewritable<'a>( &self, commits: impl IntoIterator, ) -> Result<(), CommandError> { let commit_ids = commits.into_iter().cloned().collect_vec(); let to_rewrite_expr = RevsetExpression::commits(commit_ids); - self.check_rewritable_expr(&to_rewrite_expr) + self.check_rewritable_expr(&to_rewrite_expr).await } - pub fn check_rewritable_expr( + pub async fn check_rewritable_expr( &self, to_rewrite_expr: &Arc, ) -> Result<(), CommandError> { @@ -1901,7 +1915,7 @@ to the current parents may contain changes from multiple commits. user_error(format!("The root commit {commit_id:.12} is immutable")) } else { let mut error = user_error(format!("Commit {commit_id:.12} is immutable")); - let commit = repo.store().get_commit(&commit_id)?; + let commit = repo.store().get_commit_async(&commit_id).await?; error.add_formatted_hint_with(|formatter| { write!(formatter, "Could not modify commit: ")?; self.write_commit_summary(formatter, &commit)?; @@ -1959,7 +1973,7 @@ to the current parents may contain changes from multiple commits. .map_err(snapshot_command_error)?; let Some((repo, wc_commit)) = - handle_stale_working_copy(locked_ws.locked_wc(), repo, &workspace_name)? + handle_stale_working_copy(locked_ws.locked_wc(), repo, &workspace_name).await? else { // If the workspace has been deleted, it's unclear what to do, so we just skip // committing the working copy. @@ -2010,6 +2024,7 @@ to the current parents may contain changes from multiple commits. let old_tree = wc_commit.tree(); let new_tree = commit.tree(); export_working_copy_changes_to_git(ui, mut_repo, &old_tree, &new_tree) + .await .map_err(snapshot_command_error)?; } @@ -2056,7 +2071,7 @@ to the current parents may contain changes from multiple commits. Ok(stats) } - fn update_working_copy( + async fn update_working_copy( &mut self, ui: &Ui, maybe_old_commit: Option<&Commit>, @@ -2068,7 +2083,8 @@ to the current parents may contain changes from multiple commits. &mut self.workspace, maybe_old_commit, new_commit, - )?; + ) + .await?; self.print_updated_working_copy_stats(ui, maybe_old_commit, new_commit, &stats) } @@ -2118,14 +2134,14 @@ to the current parents may contain changes from multiple commits. } } - fn finish_transaction( + async fn finish_transaction( &mut self, ui: &Ui, mut tx: Transaction, description: impl Into, _git_import_export_lock: &GitImportExportLock, ) -> Result<(), CommandError> { - let num_rebased = tx.repo_mut().rebase_descendants().block_on()?; + let num_rebased = tx.repo_mut().rebase_descendants().await?; if num_rebased > 0 { writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?; } @@ -2148,10 +2164,8 @@ to the current parents may contain changes from multiple commits. } }; if is_immutable { - let wc_commit = tx.repo().store().get_commit(wc_commit_id)?; - tx.repo_mut() - .check_out(name.clone(), &wc_commit) - .block_on()?; + let wc_commit = tx.repo().store().get_commit_async(wc_commit_id).await?; + tx.repo_mut().check_out(name.clone(), &wc_commit).await?; writeln!( ui.warning_default(), "The working-copy commit in workspace '{name}' became immutable, so a new \ @@ -2200,7 +2214,7 @@ to the current parents may contain changes from multiple commits. // This can still fail if HEAD was updated concurrently by another JJ process // (overlapping transaction) or a non-JJ process (e.g., git checkout). In that // case, the actual state will be imported on the next snapshot. - match jj_lib::git::reset_head(tx.repo_mut(), wc_commit).block_on() { + match jj_lib::git::reset_head(tx.repo_mut(), wc_commit).await { Ok(()) => {} Err(err @ jj_lib::git::GitResetHeadError::UpdateHeadRef(_)) => { writeln!(ui.warning_default(), "{err}")?; @@ -2213,14 +2227,15 @@ to the current parents may contain changes from multiple commits. crate::git_util::print_git_export_stats(ui, &stats)?; } - self.user_repo = ReadonlyUserRepo::new(tx.commit(description).block_on()?); + self.user_repo = ReadonlyUserRepo::new(tx.commit(description).await?); // Update working copy before reporting repo changes, so that // potential errors while reporting changes (broken pipe, etc) // don't leave the working copy in a stale state. if self.may_update_working_copy { if let Some(new_commit) = &maybe_new_wc_commit { - self.update_working_copy(ui, maybe_old_wc_commit.as_ref(), new_commit)?; + self.update_working_copy(ui, maybe_old_wc_commit.as_ref(), new_commit) + .await?; } else { // It seems the workspace was deleted, so we shouldn't try to // update it. @@ -2471,20 +2486,20 @@ to the current parents may contain changes from multiple commits. } #[cfg(feature = "git")] -pub fn export_working_copy_changes_to_git( +pub async fn export_working_copy_changes_to_git( ui: &Ui, mut_repo: &mut MutableRepo, old_tree: &MergedTree, new_tree: &MergedTree, ) -> Result<(), CommandError> { let repo = mut_repo.base_repo().as_ref(); - jj_lib::git::update_intent_to_add(repo, old_tree, new_tree).block_on()?; + jj_lib::git::update_intent_to_add(repo, old_tree, new_tree).await?; let stats = jj_lib::git::export_refs(mut_repo)?; crate::git_util::print_git_export_stats(ui, &stats)?; Ok(()) } #[cfg(not(feature = "git"))] -pub fn export_working_copy_changes_to_git( +pub async fn export_working_copy_changes_to_git( _ui: &Ui, _mut_repo: &mut MutableRepo, _old_tree: &MergedTree, @@ -2586,7 +2601,7 @@ impl WorkspaceCommandTransaction<'_> { self.helper.env.parse_template(ui, &language, template_text) } - pub fn finish(self, ui: &Ui, description: impl Into) -> Result<(), CommandError> { + pub async fn finish(self, ui: &Ui, description: impl Into) -> Result<(), CommandError> { if !self.tx.repo().has_changes() { writeln!(ui.status(), "Nothing changed.")?; return Ok(()); @@ -2596,6 +2611,7 @@ impl WorkspaceCommandTransaction<'_> { let git_import_export_lock = self.helper.lock_git_import_export()?; self.helper .finish_transaction(ui, self.tx, description, &git_import_export_lock) + .await } /// Returns the wrapped [`Transaction`] for circumstances where @@ -2706,7 +2722,7 @@ pub fn start_repo_transaction(repo: &Arc, string_args: &[String]) /// /// Returns Ok(None) if the workspace doesn't exist in the repo (presumably /// because it was deleted). -fn handle_stale_working_copy( +async fn handle_stale_working_copy( locked_wc: &mut dyn LockedWorkingCopy, repo: Arc, workspace_name: &WorkspaceName, @@ -2722,12 +2738,12 @@ fn handle_stale_working_copy( return Ok(None); }; let old_op_id = locked_wc.old_operation_id().clone(); - match WorkingCopyFreshness::check_stale(locked_wc, &wc_commit, &repo).block_on() { + match WorkingCopyFreshness::check_stale(locked_wc, &wc_commit, &repo).await { Ok(WorkingCopyFreshness::Fresh) => Ok(Some((repo, wc_commit))), Ok(WorkingCopyFreshness::Updated(wc_operation)) => { let repo = repo .reload_at(&wc_operation) - .block_on() + .await .map_err(snapshot_command_error)?; if let Some(wc_commit) = get_wc_commit(&repo)? { Ok(Some((repo, wc_commit))) @@ -2776,8 +2792,8 @@ See https://docs.jj-vcs.dev/latest/working-copy/#stale-working-copy \ } } -fn update_stale_working_copy( - mut locked_ws: LockedWorkspace, +async fn update_stale_working_copy( + mut locked_ws: LockedWorkspace<'_>, op_id: OperationId, stale_commit: &Commit, new_commit: &Commit, @@ -2792,14 +2808,14 @@ fn update_stale_working_copy( let stats = locked_ws .locked_wc() .check_out(new_commit) - .block_on() + .await .map_err(|err| { internal_error_with_message( format!("Failed to check out commit {}", new_commit.id().hex()), err, ) })?; - locked_ws.finish(op_id).block_on()?; + locked_ws.finish(op_id).await?; Ok(stats) } @@ -3082,7 +3098,7 @@ pub fn print_unmatched_explicit_paths<'a>( Ok(()) } -pub fn update_working_copy( +pub async fn update_working_copy( repo: &Arc, workspace: &mut Workspace, old_commit: Option<&Commit>, @@ -3093,7 +3109,7 @@ pub fn update_working_copy( // warning for most commands (but be an error for the checkout command) let stats = workspace .check_out(repo.op_id().clone(), old_tree.as_ref(), new_commit) - .block_on() + .await .map_err(|err| { internal_error_with_message( format!("Failed to check out commit {}", new_commit.id().hex()), @@ -3325,7 +3341,7 @@ impl fmt::Display for RemoteBookmarkNamePattern { /// /// The `destination` argument is mutually exclusive to the `insert_after` and /// `insert_before` arguments. -pub fn compute_commit_location( +pub async fn compute_commit_location( ui: &Ui, workspace_command: &WorkspaceCommandHelper, destination: Option<&[RevisionArg]>, @@ -3390,7 +3406,9 @@ pub fn compute_commit_location( }; if !new_child_ids.is_empty() { - workspace_command.check_rewritable(new_child_ids.iter())?; + workspace_command + .check_rewritable(new_child_ids.iter()) + .await?; ensure_no_commit_loop( workspace_command.repo().as_ref(), &RevsetExpression::commits(new_child_ids.clone()), diff --git a/cli/src/commands/abandon.rs b/cli/src/commands/abandon.rs index 1b5ee6ece17..70aa03786c7 100644 --- a/cli/src/commands/abandon.rs +++ b/cli/src/commands/abandon.rs @@ -80,7 +80,9 @@ pub(crate) async fn cmd_abandon( } .resolve()?; let visible_expr = target_expr.intersection(&RevsetExpression::visible_heads().ancestors()); - workspace_command.check_rewritable_expr(&visible_expr)?; + workspace_command + .check_rewritable_expr(&visible_expr) + .await?; let visible: IndexSet<_> = visible_expr .evaluate(workspace_command.repo().as_ref())? .stream() @@ -182,7 +184,7 @@ pub(crate) async fn cmd_abandon( to_abandon.len() - 1 ) }; - tx.finish(ui, transaction_description)?; + tx.finish(ui, transaction_description).await?; #[cfg(feature = "git")] if jj_lib::git::get_git_backend(workspace_command.repo().store()).is_ok() { diff --git a/cli/src/commands/absorb.rs b/cli/src/commands/absorb.rs index 06448083ad9..d2fe6a1097a 100644 --- a/cli/src/commands/absorb.rs +++ b/cli/src/commands/absorb.rs @@ -98,7 +98,9 @@ pub(crate) async fn cmd_absorb( writeln!(ui.warning_default(), "Skipping {ui_path}: {reason}")?; } - workspace_command.check_rewritable(selected_trees.target_commits.keys())?; + workspace_command + .check_rewritable(selected_trees.target_commits.keys()) + .await?; let mut tx = workspace_command.start_transaction(); let stats = absorb_hunks(tx.repo_mut(), &source, selected_trees.target_commits).await?; @@ -131,7 +133,8 @@ pub(crate) async fn cmd_absorb( "absorb changes into {} commits", stats.rewritten_destinations.len() ), - )?; + ) + .await?; if let Some(mut formatter) = ui.status_formatter() && let Some(commit) = &stats.rewritten_source diff --git a/cli/src/commands/arrange.rs b/cli/src/commands/arrange.rs index 3aed0a1282a..1fd4f180cbf 100644 --- a/cli/src/commands/arrange.rs +++ b/cli/src/commands/arrange.rs @@ -98,7 +98,9 @@ pub(crate) async fn cmd_arrange( .parse_union_revsets(ui, &[&*args.revisions_pos, &*args.revisions_opt].concat())? } .resolve()?; - workspace_command.check_rewritable_expr(&target_expression)?; + workspace_command + .check_rewritable_expr(&target_expression) + .await?; let gaps_revset = target_expression .connected() @@ -156,7 +158,7 @@ pub(crate) async fn cmd_arrange( let mut tx = workspace_command.start_transaction(); let rewrites = new_state.to_rewrite_plan(); rewrites.execute(tx.repo_mut()).await?; - tx.finish(ui, "arrange revisions")?; + tx.finish(ui, "arrange revisions").await?; Ok(()) } else { Err(user_error("Canceled by user")) diff --git a/cli/src/commands/bisect/run.rs b/cli/src/commands/bisect/run.rs index c78d6915713..b9254de27c9 100644 --- a/cli/src/commands/bisect/run.rs +++ b/cli/src/commands/bisect/run.rs @@ -146,7 +146,7 @@ pub(crate) async fn cmd_bisect_run( } let cmd = get_command(args); - let evaluation = evaluate_commit(ui, &mut workspace_command, cmd, &commit)?; + let evaluation = evaluate_commit(ui, &mut workspace_command, cmd, &commit).await?; { let mut formatter = ui.stdout_formatter(); @@ -232,7 +232,7 @@ fn get_command(args: &BisectRunArgs) -> std::process::Command { } } -fn evaluate_commit( +async fn evaluate_commit( ui: &mut Ui, workspace_command: &mut WorkspaceCommandHelper, mut cmd: std::process::Command, @@ -244,7 +244,8 @@ fn evaluate_commit( tx.finish( ui, format!("Updated to revision {commit_id_hex} for bisection"), - )?; + ) + .await?; let jj_executable_path = std::env::current_exe().map_err(|err| { internal_error_with_message("Could not get path for the jj executable", err) diff --git a/cli/src/commands/bookmark/advance.rs b/cli/src/commands/bookmark/advance.rs index e8f0f40093c..96a2f0bc3b5 100644 --- a/cli/src/commands/bookmark/advance.rs +++ b/cli/src/commands/bookmark/advance.rs @@ -212,6 +212,7 @@ pub async fn cmd_bookmark_advance( .join(", "), id = target_commit.id().hex() ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/bookmark/create.rs b/cli/src/commands/bookmark/create.rs index 56c7d42f890..05c9fabdb80 100644 --- a/cli/src/commands/bookmark/create.rs +++ b/cli/src/commands/bookmark/create.rs @@ -122,6 +122,7 @@ pub async fn cmd_bookmark_create( names = bookmark_names.iter().map(|n| n.as_symbol()).join(", "), id = target_commit.id().hex() ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/bookmark/delete.rs b/cli/src/commands/bookmark/delete.rs index 8d7b9927895..2a4940bf098 100644 --- a/cli/src/commands/bookmark/delete.rs +++ b/cli/src/commands/bookmark/delete.rs @@ -85,6 +85,7 @@ pub async fn cmd_bookmark_delete( .map(|(name, _)| name.as_symbol()) .join(", ") ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/bookmark/forget.rs b/cli/src/commands/bookmark/forget.rs index e19a11608f2..33a772f9822 100644 --- a/cli/src/commands/bookmark/forget.rs +++ b/cli/src/commands/bookmark/forget.rs @@ -106,7 +106,8 @@ pub async fn cmd_bookmark_forget( .iter() .map(|(name, _)| name.as_symbol()) .join(", "); - tx.finish(ui, format!("forget bookmark {forgotten_bookmarks}"))?; + tx.finish(ui, format!("forget bookmark {forgotten_bookmarks}")) + .await?; Ok(()) } diff --git a/cli/src/commands/bookmark/move.rs b/cli/src/commands/bookmark/move.rs index 574a250bcd1..bd63a94e2c1 100644 --- a/cli/src/commands/bookmark/move.rs +++ b/cli/src/commands/bookmark/move.rs @@ -160,6 +160,7 @@ pub async fn cmd_bookmark_move( .join(", "), id = target_commit.id().hex() ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/bookmark/rename.rs b/cli/src/commands/bookmark/rename.rs index 9d842d84244..34caac56f61 100644 --- a/cli/src/commands/bookmark/rename.rs +++ b/cli/src/commands/bookmark/rename.rs @@ -165,7 +165,8 @@ pub async fn cmd_bookmark_rename( old_bookmark = old_bookmark.as_symbol(), new_bookmark = new_bookmark.as_symbol() ), - )?; + ) + .await?; if tracked_present_old_remotes_exist { writeln!( diff --git a/cli/src/commands/bookmark/set.rs b/cli/src/commands/bookmark/set.rs index 27b53e2ea54..3e8073d43ae 100644 --- a/cli/src/commands/bookmark/set.rs +++ b/cli/src/commands/bookmark/set.rs @@ -142,6 +142,7 @@ pub async fn cmd_bookmark_set( names = bookmark_names.iter().map(|n| n.as_symbol()).join(", "), id = target_commit.id().hex() ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/bookmark/track.rs b/cli/src/commands/bookmark/track.rs index 6236343e292..5398ea939e9 100644 --- a/cli/src/commands/bookmark/track.rs +++ b/cli/src/commands/bookmark/track.rs @@ -133,7 +133,8 @@ pub async fn cmd_bookmark_track( tx.finish( ui, format!("track remote bookmark {}", symbols.iter().join(", ")), - )?; + ) + .await?; //show conflicted bookmarks if there are some diff --git a/cli/src/commands/bookmark/untrack.rs b/cli/src/commands/bookmark/untrack.rs index a0ed21fb117..3230994ebd8 100644 --- a/cli/src/commands/bookmark/untrack.rs +++ b/cli/src/commands/bookmark/untrack.rs @@ -137,6 +137,7 @@ pub async fn cmd_bookmark_untrack( tx.finish( ui, format!("untrack remote bookmark {}", symbols.iter().join(", ")), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/commit.rs b/cli/src/commands/commit.rs index 5b326d4be77..ef0601759ff 100644 --- a/cli/src/commands/commit.rs +++ b/cli/src/commands/commit.rs @@ -239,6 +239,7 @@ new working-copy commit. tx.repo_mut().edit(name, &new_wc_commit).await.unwrap(); } } - tx.finish(ui, format!("commit {}", commit.id().hex()))?; + tx.finish(ui, format!("commit {}", commit.id().hex())) + .await?; Ok(()) } diff --git a/cli/src/commands/describe.rs b/cli/src/commands/describe.rs index 1002648c16a..f52cddf1224 100644 --- a/cli/src/commands/describe.rs +++ b/cli/src/commands/describe.rs @@ -164,7 +164,9 @@ pub(crate) async fn cmd_describe( workspace_command.parse_revset(ui, &RevisionArg::AT)? } .resolve()?; - workspace_command.check_rewritable_expr(&target_expr)?; + workspace_command + .check_rewritable_expr(&target_expr) + .await?; let commits: Vec<_> = target_expr .evaluate(workspace_command.repo().as_ref())? .stream() @@ -344,6 +346,6 @@ pub(crate) async fn cmd_describe( if num_reparented > 0 { writeln!(ui.status(), "Rebased {num_reparented} descendant commits")?; } - tx.finish(ui, tx_description)?; + tx.finish(ui, tx_description).await?; Ok(()) } diff --git a/cli/src/commands/diffedit.rs b/cli/src/commands/diffedit.rs index 1c6dfa9f562..ab8f3266968 100644 --- a/cli/src/commands/diffedit.rs +++ b/cli/src/commands/diffedit.rs @@ -116,7 +116,9 @@ pub(crate) async fn cmd_diffedit( base_commits = target_commit.parents().await?; diff_description = "The diff initially shows the commit's changes.".to_string(); } - workspace_command.check_rewritable([target_commit.id()])?; + workspace_command + .check_rewritable([target_commit.id()]) + .await?; let diff_editor = workspace_command.diff_editor(ui, args.tool.as_deref())?; let mut tx = workspace_command.start_transaction(); @@ -163,7 +165,8 @@ don't make any changes, then the operation will be aborted.", "Rebased {num_rebased} descendant commits{extra_msg}" )?; } - tx.finish(ui, format!("edit commit {}", target_commit.id().hex()))?; + tx.finish(ui, format!("edit commit {}", target_commit.id().hex())) + .await?; } print_unmatched_explicit_paths( ui, diff --git a/cli/src/commands/duplicate.rs b/cli/src/commands/duplicate.rs index 74144026394..93694fe8b77 100644 --- a/cli/src/commands/duplicate.rs +++ b/cli/src/commands/duplicate.rs @@ -126,14 +126,17 @@ pub(crate) async fn cmd_duplicate( if args.onto.is_none() && args.insert_after.is_none() && args.insert_before.is_none() { None } else { - Some(compute_commit_location( - ui, - &workspace_command, - args.onto.as_deref(), - args.insert_after.as_deref(), - args.insert_before.as_deref(), - "duplicated commits", - )?) + Some( + compute_commit_location( + ui, + &workspace_command, + args.onto.as_deref(), + args.insert_after.as_deref(), + args.insert_before.as_deref(), + "duplicated commits", + ) + .await?, + ) }; let mut tx = workspace_command.start_transaction(); @@ -215,6 +218,7 @@ pub(crate) async fn cmd_duplicate( )?; } } - tx.finish(ui, format!("duplicate {num_to_duplicate} commit(s)"))?; + tx.finish(ui, format!("duplicate {num_to_duplicate} commit(s)")) + .await?; Ok(()) } diff --git a/cli/src/commands/edit.rs b/cli/src/commands/edit.rs index eebb739cf92..60049259abd 100644 --- a/cli/src/commands/edit.rs +++ b/cli/src/commands/edit.rs @@ -57,13 +57,16 @@ pub(crate) async fn cmd_edit( .or(args.revision_opt.as_ref()) .expect("either positional or -r arg should be provided"); let new_commit = workspace_command.resolve_single_rev(ui, revision_arg)?; - workspace_command.check_rewritable([new_commit.id()])?; + workspace_command + .check_rewritable([new_commit.id()]) + .await?; if workspace_command.get_wc_commit_id() == Some(new_commit.id()) { writeln!(ui.status(), "Already editing that commit")?; } else { let mut tx = workspace_command.start_transaction(); tx.edit(&new_commit)?; - tx.finish(ui, format!("edit commit {}", new_commit.id().hex()))?; + tx.finish(ui, format!("edit commit {}", new_commit.id().hex())) + .await?; } Ok(()) } diff --git a/cli/src/commands/file/chmod.rs b/cli/src/commands/file/chmod.rs index 4653d86ec19..aa77106f763 100644 --- a/cli/src/commands/file/chmod.rs +++ b/cli/src/commands/file/chmod.rs @@ -70,7 +70,7 @@ pub(crate) async fn cmd_file_chmod( let mut workspace_command = command.workspace_helper(ui)?; let commit = workspace_command.resolve_single_rev(ui, &args.revision)?; - workspace_command.check_rewritable([commit.id()])?; + workspace_command.check_rewritable([commit.id()]).await?; let tree = commit.tree(); // TODO: No need to add special case for empty paths when switching to // parse_union_filesets(). paths = [] should be "none()" if supported. @@ -132,4 +132,5 @@ pub(crate) async fn cmd_file_chmod( commit.id().hex(), ), ) + .await } diff --git a/cli/src/commands/file/untrack.rs b/cli/src/commands/file/untrack.rs index 99e879aace2..d7de5426d9d 100644 --- a/cli/src/commands/file/untrack.rs +++ b/cli/src/commands/file/untrack.rs @@ -106,7 +106,7 @@ Make sure they're ignored, then try again.", writeln!(ui.status(), "Rebased {num_rebased} descendant commits")?; } if working_copy_shared_with_git { - export_working_copy_changes_to_git(ui, tx.repo_mut(), &wc_tree, &new_commit.tree())?; + export_working_copy_changes_to_git(ui, tx.repo_mut(), &wc_tree, &new_commit.tree()).await?; } let repo = tx.commit("untrack paths").await?; locked_ws.finish(repo.op_id().clone()).await?; diff --git a/cli/src/commands/fix.rs b/cli/src/commands/fix.rs index 7e2cdbf4c8a..8aa7359ab86 100644 --- a/cli/src/commands/fix.rs +++ b/cli/src/commands/fix.rs @@ -194,7 +194,9 @@ pub(crate) async fn cmd_fix( workspace_command.parse_union_revsets(ui, &args.source)? } .resolve()?; - workspace_command.check_rewritable_expr(&target_expr)?; + workspace_command + .check_rewritable_expr(&target_expr) + .await?; let repo = workspace_command.repo(); @@ -246,6 +248,7 @@ pub(crate) async fn cmd_fix( summary.num_checked_commits )?; tx.finish(ui, format!("fixed {} commits", summary.num_fixed_commits)) + .await } /// Invokes all matching tools (if any) to file_to_fix. If the content is diff --git a/cli/src/commands/gerrit/upload.rs b/cli/src/commands/gerrit/upload.rs index 5a5c266c005..9e4d03e8921 100644 --- a/cli/src/commands/gerrit/upload.rs +++ b/cli/src/commands/gerrit/upload.rs @@ -423,7 +423,9 @@ pub async fn cmd_gerrit_upload( let target_expr = workspace_command .parse_union_revsets(ui, &args.revisions)? .resolve()?; - workspace_command.check_rewritable_expr(&target_expr)?; + workspace_command + .check_rewritable_expr(&target_expr) + .await?; target_expr .evaluate(workspace_command.repo().as_ref())? .stream() diff --git a/cli/src/commands/git/clone.rs b/cli/src/commands/git/clone.rs index b84bfa1ca7e..54d019b8ebc 100644 --- a/cli/src/commands/git/clone.rs +++ b/cli/src/commands/git/clone.rs @@ -266,7 +266,8 @@ pub async fn cmd_git_clone( tx.finish( ui, format!("check out git remote's branch: {}", name.as_symbol()), - )?; + ) + .await?; } } @@ -315,7 +316,8 @@ async fn configure_remote( fetch_tags.as_fetch_tags(), &ref_expr.bookmark, )?; - tx.finish(ui, format!("add git remote {}", remote_name.as_symbol()))?; + tx.finish(ui, format!("add git remote {}", remote_name.as_symbol())) + .await?; // Reload workspace to apply new remote configuration to // gix::ThreadSafeRepository behind the store. let workspace = command.load_workspace_at( @@ -436,6 +438,7 @@ async fn fetch_new_remote( `git.auto-local-bookmark` is enabled." )?; } - tx.finish(ui, "fetch from git remote into empty repo")?; + tx.finish(ui, "fetch from git remote into empty repo") + .await?; Ok((working_branch.map(ToOwned::to_owned), working_is_default)) } diff --git a/cli/src/commands/git/colocation.rs b/cli/src/commands/git/colocation.rs index d5fd140e4bd..250de41c7ad 100644 --- a/cli/src/commands/git/colocation.rs +++ b/cli/src/commands/git/colocation.rs @@ -253,7 +253,7 @@ async fn cmd_git_colocation_disable( let mut workspace_command = reload_workspace_helper(ui, command, workspace_command).await?; // And finally, remove the git HEAD reference - remove_git_head(ui, &mut workspace_command)?; + remove_git_head(ui, &mut workspace_command).await?; writeln!( ui.status(), @@ -301,20 +301,20 @@ async fn set_git_head_to_wc_parent( let mut tx = workspace_command.start_transaction(); git::reset_head(tx.repo_mut(), wc_commit).await?; if tx.repo().has_changes() { - tx.finish(ui, "set git head to working copy parent")?; + tx.finish(ui, "set git head to working copy parent").await?; } Ok(()) } /// Remove the git HEAD reference -fn remove_git_head( +async fn remove_git_head( ui: &mut Ui, workspace_command: &mut crate::cli_util::WorkspaceCommandHelper, ) -> Result<(), CommandError> { let mut tx = workspace_command.start_transaction(); tx.repo_mut().set_git_head_target(RefTarget::absent()); if tx.repo().has_changes() { - tx.finish(ui, "remove git head reference")?; + tx.finish(ui, "remove git head reference").await?; } Ok(()) } diff --git a/cli/src/commands/git/export.rs b/cli/src/commands/git/export.rs index c94679f1a68..1df4544aa5c 100644 --- a/cli/src/commands/git/export.rs +++ b/cli/src/commands/git/export.rs @@ -34,7 +34,7 @@ pub async fn cmd_git_export( let mut workspace_command = command.workspace_helper(ui)?; let mut tx = workspace_command.start_transaction(); let stats = git::export_refs(tx.repo_mut())?; - tx.finish(ui, "export git refs")?; + tx.finish(ui, "export git refs").await?; print_git_export_stats(ui, &stats)?; Ok(()) } diff --git a/cli/src/commands/git/fetch.rs b/cli/src/commands/git/fetch.rs index 6c6d5f2fdd4..3d67063c2d8 100644 --- a/cli/src/commands/git/fetch.rs +++ b/cli/src/commands/git/fetch.rs @@ -242,7 +242,8 @@ pub async fn cmd_git_fetch( "fetch from git remote(s) {}", matching_remotes.iter().map(|n| n.as_symbol()).join(",") ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/git/import.rs b/cli/src/commands/git/import.rs index 78ac35d16f0..2f5584cfdd3 100644 --- a/cli/src/commands/git/import.rs +++ b/cli/src/commands/git/import.rs @@ -46,6 +46,6 @@ pub async fn cmd_git_import( git::import_head(tx.repo_mut()).await?; let stats = git::import_refs(tx.repo_mut(), &import_options).await?; print_git_import_stats(ui, &tx, &stats)?; - tx.finish(ui, "import git refs")?; + tx.finish(ui, "import git refs").await?; Ok(()) } diff --git a/cli/src/commands/git/init.rs b/cli/src/commands/git/init.rs index 953aa293c18..4f416054298 100644 --- a/cli/src/commands/git/init.rs +++ b/cli/src/commands/git/init.rs @@ -214,7 +214,7 @@ async fn do_init( let repo = init_git_refs(ui, repo, command.string_args(), colocated).await?; let mut workspace_command = command.for_workable_repo(ui, workspace, repo)?; maybe_add_gitignore(&workspace_command)?; - workspace_command.maybe_snapshot(ui)?; + workspace_command.maybe_snapshot(ui).await?; maybe_set_repository_level_trunk_alias( ui, &git::get_git_repo(workspace_command.repo().store())?, @@ -228,7 +228,7 @@ async fn do_init( tx.check_out(&git_head_commit)?; } if tx.repo().has_changes() { - tx.finish(ui, "import git head")?; + tx.finish(ui, "import git head").await?; } } print_trackable_remote_bookmarks(ui, workspace_command.repo().view())?; diff --git a/cli/src/commands/git/push.rs b/cli/src/commands/git/push.rs index fa377d44f6f..91e4b8cc275 100644 --- a/cli/src/commands/git/push.rs +++ b/cli/src/commands/git/push.rs @@ -493,7 +493,7 @@ pub async fn cmd_git_push( // TODO: On partial success, locally-created --change/--named bookmarks will // be committed. It's probably better to remove failed local bookmarks. if push_stats.all_ok() || push_stats.some_exported() { - tx.finish(ui, tx_description)?; + tx.finish(ui, tx_description).await?; } if push_stats.all_ok() { Ok(()) diff --git a/cli/src/commands/git/remote/add.rs b/cli/src/commands/git/remote/add.rs index 6b41bbac464..d826e4ebfaf 100644 --- a/cli/src/commands/git/remote/add.rs +++ b/cli/src/commands/git/remote/add.rs @@ -69,6 +69,7 @@ pub async fn cmd_git_remote_add( args.fetch_tags.as_fetch_tags(), &bookmark_expr, )?; - tx.finish(ui, format!("add git remote {}", args.remote.as_symbol()))?; + tx.finish(ui, format!("add git remote {}", args.remote.as_symbol())) + .await?; Ok(()) } diff --git a/cli/src/commands/git/remote/remove.rs b/cli/src/commands/git/remote/remove.rs index eeb3f67bedd..ed1a77881d2 100644 --- a/cli/src/commands/git/remote/remove.rs +++ b/cli/src/commands/git/remote/remove.rs @@ -39,6 +39,7 @@ pub async fn cmd_git_remote_remove( git::remove_remote(tx.repo_mut(), &args.remote)?; if tx.repo().has_changes() { tx.finish(ui, format!("remove git remote {}", args.remote.as_symbol())) + .await } else { // Do not print "Nothing changed." for the remote named "git". Ok(()) diff --git a/cli/src/commands/git/remote/rename.rs b/cli/src/commands/git/remote/rename.rs index 8eb9c2b5eba..00d5be63166 100644 --- a/cli/src/commands/git/remote/rename.rs +++ b/cli/src/commands/git/remote/rename.rs @@ -49,6 +49,7 @@ pub async fn cmd_git_remote_rename( new = args.new.as_symbol() ), ) + .await } else { Ok(()) // Do not print "Nothing changed." } diff --git a/cli/src/commands/metaedit.rs b/cli/src/commands/metaedit.rs index 5f121b3140c..1546cc44376 100644 --- a/cli/src/commands/metaedit.rs +++ b/cli/src/commands/metaedit.rs @@ -162,7 +162,9 @@ pub(crate) async fn cmd_metaedit( workspace_command.parse_revset(ui, &RevisionArg::AT)? } .resolve()?; - workspace_command.check_rewritable_expr(&target_expr)?; + workspace_command + .check_rewritable_expr(&target_expr) + .await?; let commit_ids: Vec<_> = target_expr .evaluate(workspace_command.repo().as_ref())? .stream() @@ -268,6 +270,6 @@ pub(crate) async fn cmd_metaedit( if num_reparented > 0 { writeln!(ui.status(), "Rebased {num_reparented} descendant commits")?; } - tx.finish(ui, tx_description)?; + tx.finish(ui, tx_description).await?; Ok(()) } diff --git a/cli/src/commands/new.rs b/cli/src/commands/new.rs index 270d08b2c82..d3e7885d423 100644 --- a/cli/src/commands/new.rs +++ b/cli/src/commands/new.rs @@ -183,7 +183,8 @@ pub(crate) async fn cmd_new( args.insert_after.as_deref(), args.insert_before.as_deref(), "new commit", - )?; + ) + .await?; let parent_commits: Vec<_> = parent_commit_ids .iter() .map(|commit_id| workspace_command.repo().store().get_commit(commit_id)) @@ -276,6 +277,6 @@ pub(crate) async fn cmd_new( tx.advance_bookmarks(advanceable_bookmarks, &target)?; } - tx.finish(ui, "new empty commit")?; + tx.finish(ui, "new empty commit").await?; Ok(()) } diff --git a/cli/src/commands/next.rs b/cli/src/commands/next.rs index ff6e4b15de5..01ea93a3945 100644 --- a/cli/src/commands/next.rs +++ b/cli/src/commands/next.rs @@ -92,5 +92,5 @@ pub(crate) async fn cmd_next( command: &CommandHelper, args: &NextArgs, ) -> Result<(), CommandError> { - move_to_commit(ui, command, Direction::Next, &MovementArgs::from(args)) + move_to_commit(ui, command, Direction::Next, &MovementArgs::from(args)).await } diff --git a/cli/src/commands/operation/restore.rs b/cli/src/commands/operation/restore.rs index 7183d94882e..23c085de797 100644 --- a/cli/src/commands/operation/restore.rs +++ b/cli/src/commands/operation/restore.rs @@ -64,7 +64,8 @@ pub async fn cmd_op_restore( template.format(&target_op, formatter.as_mut())?; writeln!(formatter)?; } - tx.finish(ui, format!("restore to operation {}", target_op.id().hex()))?; + tx.finish(ui, format!("restore to operation {}", target_op.id().hex())) + .await?; Ok(()) } diff --git a/cli/src/commands/operation/revert.rs b/cli/src/commands/operation/revert.rs index fccd63a372d..5b8815737e8 100644 --- a/cli/src/commands/operation/revert.rs +++ b/cli/src/commands/operation/revert.rs @@ -81,7 +81,7 @@ pub async fn cmd_op_revert( template.format(&bad_op, formatter.as_mut())?; writeln!(formatter)?; } - tx.finish(ui, tx_description(&bad_op))?; + tx.finish(ui, tx_description(&bad_op)).await?; Ok(()) } diff --git a/cli/src/commands/parallelize.rs b/cli/src/commands/parallelize.rs index 636006a46b4..1a861796a4f 100644 --- a/cli/src/commands/parallelize.rs +++ b/cli/src/commands/parallelize.rs @@ -98,7 +98,7 @@ pub(crate) async fn cmd_parallelize( new_target_parents.insert(commit.id().clone(), new_parents); } - workspace_command.check_rewritable(needs_rewrite)?; + workspace_command.check_rewritable(needs_rewrite).await?; let mut tx = workspace_command.start_transaction(); // If a commit outside the target set has a commit in the target set as parent, @@ -150,4 +150,5 @@ pub(crate) async fn cmd_parallelize( .await?; tx.finish(ui, format!("parallelize {} commits", target_commits.len())) + .await } diff --git a/cli/src/commands/prev.rs b/cli/src/commands/prev.rs index c3f55e84bfe..fee124bbe37 100644 --- a/cli/src/commands/prev.rs +++ b/cli/src/commands/prev.rs @@ -88,5 +88,5 @@ pub(crate) async fn cmd_prev( command: &CommandHelper, args: &PrevArgs, ) -> Result<(), CommandError> { - move_to_commit(ui, command, Direction::Prev, &MovementArgs::from(args)) + move_to_commit(ui, command, Direction::Prev, &MovementArgs::from(args)).await } diff --git a/cli/src/commands/rebase.rs b/cli/src/commands/rebase.rs index f6780c4d886..ce9b9b7f299 100644 --- a/cli/src/commands/rebase.rs +++ b/cli/src/commands/rebase.rs @@ -384,11 +384,11 @@ pub(crate) async fn cmd_rebase( let mut workspace_command = command.workspace_helper(ui)?; let loc = if !args.revisions.is_empty() { - plan_rebase_revisions(ui, &workspace_command, &args.revisions, &args.destination)? + plan_rebase_revisions(ui, &workspace_command, &args.revisions, &args.destination).await? } else if !args.source.is_empty() { - plan_rebase_source(ui, &workspace_command, &args.source, &args.destination)? + plan_rebase_source(ui, &workspace_command, &args.source, &args.destination).await? } else { - plan_rebase_branch(ui, &workspace_command, &args.branch, &args.destination)? + plan_rebase_branch(ui, &workspace_command, &args.branch, &args.destination).await? }; let target_ids = match &loc.target { @@ -423,12 +423,12 @@ pub(crate) async fn cmd_rebase( } let stats = computed_move.apply(tx.repo_mut(), &rebase_options).await?; print_move_commits_stats(ui, &stats)?; - tx.finish(ui, tx_description(&loc.target))?; + tx.finish(ui, tx_description(&loc.target)).await?; Ok(()) } -fn plan_rebase_revisions( +async fn plan_rebase_revisions( ui: &Ui, workspace_command: &WorkspaceCommandHelper, revisions: &[RevisionArg], @@ -437,7 +437,9 @@ fn plan_rebase_revisions( let target_expr = workspace_command .parse_union_revsets(ui, revisions)? .resolve()?; - workspace_command.check_rewritable_expr(&target_expr)?; + workspace_command + .check_rewritable_expr(&target_expr) + .await?; let target_commit_ids: Vec<_> = target_expr .evaluate(workspace_command.repo().as_ref())? .iter() @@ -450,7 +452,8 @@ fn plan_rebase_revisions( rebase_destination.insert_after.as_deref(), rebase_destination.insert_before.as_deref(), "rebased commits", - )?; + ) + .await?; if rebase_destination.onto.is_some() { for id in &target_commit_ids { if new_parent_ids.contains(id) { @@ -468,14 +471,16 @@ fn plan_rebase_revisions( }) } -fn plan_rebase_source( +async fn plan_rebase_source( ui: &Ui, workspace_command: &WorkspaceCommandHelper, source: &[RevisionArg], rebase_destination: &RebaseDestinationArgs, ) -> Result { let source_commit_ids = Vec::from_iter(workspace_command.resolve_revsets_ordered(ui, source)?); - workspace_command.check_rewritable(&source_commit_ids)?; + workspace_command + .check_rewritable(&source_commit_ids) + .await?; let (new_parent_ids, new_child_ids) = compute_commit_location( ui, @@ -484,7 +489,8 @@ fn plan_rebase_source( rebase_destination.insert_after.as_deref(), rebase_destination.insert_before.as_deref(), "rebased commits", - )?; + ) + .await?; if rebase_destination.onto.is_some() { for id in &source_commit_ids { let commit = workspace_command.repo().store().get_commit(id)?; @@ -499,7 +505,7 @@ fn plan_rebase_source( }) } -fn plan_rebase_branch( +async fn plan_rebase_branch( ui: &Ui, workspace_command: &WorkspaceCommandHelper, branch: &[RevisionArg], @@ -526,11 +532,14 @@ fn plan_rebase_branch( rebase_destination.insert_after.as_deref(), rebase_destination.insert_before.as_deref(), "rebased commits", - )?; + ) + .await?; let roots_expression = RevsetExpression::commits(new_parent_ids.clone()) .range(&RevsetExpression::commits(branch_commit_ids)) .roots(); - workspace_command.check_rewritable_expr(&roots_expression)?; + workspace_command + .check_rewritable_expr(&roots_expression) + .await?; let root_commit_ids: Vec<_> = roots_expression .evaluate(workspace_command.repo().as_ref()) .unwrap() diff --git a/cli/src/commands/redo.rs b/cli/src/commands/redo.rs index d6cd8703c8c..f544d7b4bcb 100644 --- a/cli/src/commands/redo.rs +++ b/cli/src/commands/redo.rs @@ -168,7 +168,8 @@ pub async fn cmd_redo( tx.finish( ui, format!("{REDO_OP_DESC_PREFIX}{}", op_to_restore.id().hex()), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/resolve.rs b/cli/src/commands/resolve.rs index ce06627b8b2..24cdbc8aa8e 100644 --- a/cli/src/commands/resolve.rs +++ b/cli/src/commands/resolve.rs @@ -107,7 +107,7 @@ pub(crate) async fn cmd_resolve( .iter() .map(|(path, _)| path.as_ref()) .collect_vec(); - workspace_command.check_rewritable([commit.id()])?; + workspace_command.check_rewritable([commit.id()]).await?; let merge_editor = workspace_command.merge_editor(ui, args.tool.as_deref())?; let mut tx = workspace_command.start_transaction(); let (new_tree, partial_resolution_error) = @@ -121,7 +121,8 @@ pub(crate) async fn cmd_resolve( tx.finish( ui, format!("Resolve conflicts in commit {}", commit.id().hex()), - )?; + ) + .await?; // Print conflicts that are still present after resolution if the workspace // working copy is not at the commit. Otherwise, the conflicting paths will diff --git a/cli/src/commands/restore.rs b/cli/src/commands/restore.rs index 54a1c21d8c7..9d5ee22e16a 100644 --- a/cli/src/commands/restore.rs +++ b/cli/src/commands/restore.rs @@ -132,7 +132,7 @@ pub(crate) async fn cmd_restore( .await?; from_commits = to_commit.parents().await?; } - workspace_command.check_rewritable([to_commit.id()])?; + workspace_command.check_rewritable([to_commit.id()]).await?; let fileset_expression = workspace_command.parse_file_patterns(ui, &args.paths)?; let matcher = fileset_expression.to_matcher(); @@ -202,7 +202,8 @@ pub(crate) async fn cmd_restore( "Rebased {num_rebased} descendant commits{extra_msg}" )?; } - tx.finish(ui, format!("restore into commit {}", to_commit.id().hex()))?; + tx.finish(ui, format!("restore into commit {}", to_commit.id().hex())) + .await?; } Ok(()) } diff --git a/cli/src/commands/revert.rs b/cli/src/commands/revert.rs index 2aeecafa808..7b1e214d763 100644 --- a/cli/src/commands/revert.rs +++ b/cli/src/commands/revert.rs @@ -109,7 +109,8 @@ pub(crate) async fn cmd_revert( args.insert_after.as_deref(), args.insert_before.as_deref(), "reverted commits", - )?; + ) + .await?; let transaction_description = if to_revert.len() == 1 { format!("revert commit {}", to_revert[0].id().hex()) } else { @@ -225,7 +226,7 @@ pub(crate) async fn cmd_revert( writeln!(formatter, "Rebased {num_rebased} descendant commits")?; } } - tx.finish(ui, transaction_description)?; + tx.finish(ui, transaction_description).await?; Ok(()) } diff --git a/cli/src/commands/sign.rs b/cli/src/commands/sign.rs index 3d5efbf51c9..dc087148430 100644 --- a/cli/src/commands/sign.rs +++ b/cli/src/commands/sign.rs @@ -84,7 +84,9 @@ pub async fn cmd_sign( } .resolve()?; - workspace_command.check_rewritable_expr(&revset_expression)?; + workspace_command + .check_rewritable_expr(&revset_expression) + .await?; let to_sign: IndexSet = revset_expression .evaluate(workspace_command.repo().as_ref())? @@ -171,7 +173,7 @@ pub async fn cmd_sign( commits.len() - 1 ), }; - tx.finish(ui, transaction_description)?; + tx.finish(ui, transaction_description).await?; Ok(()) } diff --git a/cli/src/commands/simplify_parents.rs b/cli/src/commands/simplify_parents.rs index 14494e07773..9b5f043af6f 100644 --- a/cli/src/commands/simplify_parents.rs +++ b/cli/src/commands/simplify_parents.rs @@ -61,7 +61,7 @@ pub(crate) async fn cmd_simplify_parents( .resolve()?, ) }; - workspace_command.check_rewritable_expr(&revs)?; + workspace_command.check_rewritable_expr(&revs).await?; let commit_ids: Vec<_> = revs .evaluate(workspace_command.repo().as_ref())? .stream() @@ -115,7 +115,8 @@ pub(crate) async fn cmd_simplify_parents( )?; } } - tx.finish(ui, format!("simplify {num_orig_commits} commits"))?; + tx.finish(ui, format!("simplify {num_orig_commits} commits")) + .await?; Ok(()) } diff --git a/cli/src/commands/split.rs b/cli/src/commands/split.rs index f8afa765906..2664fe94fd2 100644 --- a/cli/src/commands/split.rs +++ b/cli/src/commands/split.rs @@ -207,7 +207,9 @@ impl SplitArgs { workspace_command: &WorkspaceCommandHelper, ) -> Result { let target_commit = workspace_command.resolve_single_rev(ui, &self.revision)?; - workspace_command.check_rewritable([target_commit.id()])?; + workspace_command + .check_rewritable([target_commit.id()]) + .await?; let repo = workspace_command.repo(); let fileset_expression = workspace_command.parse_file_patterns(ui, &self.paths)?; let matcher = fileset_expression.to_matcher(); @@ -226,7 +228,8 @@ impl SplitArgs { self.insert_after.as_deref(), self.insert_before.as_deref(), "split-out commit", - )? + ) + .await? } else { Default::default() }; @@ -411,7 +414,8 @@ pub(crate) async fn cmd_split( tx.write_commit_summary(formatter.as_mut(), &second_commit)?; writeln!(formatter)?; } - tx.finish(ui, format!("split commit {}", target.commit.id().hex()))?; + tx.finish(ui, format!("split commit {}", target.commit.id().hex())) + .await?; Ok(()) } diff --git a/cli/src/commands/squash.rs b/cli/src/commands/squash.rs index 65b76828cc4..aec3b44fea5 100644 --- a/cli/src/commands/squash.rs +++ b/cli/src/commands/squash.rs @@ -226,7 +226,9 @@ pub(crate) async fn cmd_squash( pre_existing_destination = Some(parents.pop().unwrap()); } - workspace_command.check_rewritable(sources.iter().chain(&pre_existing_destination).ids())?; + workspace_command + .check_rewritable(sources.iter().chain(&pre_existing_destination).ids()) + .await?; // prepare the tx description before possibly rebasing the source commits let source_ids: Vec<_> = sources.iter().ids().collect(); @@ -255,7 +257,8 @@ pub(crate) async fn cmd_squash( args.insert_after.as_deref(), args.insert_before.as_deref(), "squashed commit", - )?; + ) + .await?; let parent_commits: Vec<_> = parent_ids .iter() .map(|commit_id| { @@ -429,7 +432,7 @@ pub(crate) async fn cmd_squash( } } } - tx.finish(ui, tx_description)?; + tx.finish(ui, tx_description).await?; Ok(()) } diff --git a/cli/src/commands/tag/delete.rs b/cli/src/commands/tag/delete.rs index db156038812..d6041bffffe 100644 --- a/cli/src/commands/tag/delete.rs +++ b/cli/src/commands/tag/delete.rs @@ -68,6 +68,7 @@ pub async fn cmd_tag_delete( "delete tag {names}", names = matched_tags.iter().map(|(n, _)| n.as_symbol()).join(", ") ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/tag/set.rs b/cli/src/commands/tag/set.rs index 13a962338e7..f20163e59a5 100644 --- a/cli/src/commands/tag/set.rs +++ b/cli/src/commands/tag/set.rs @@ -108,6 +108,7 @@ pub async fn cmd_tag_set( names = args.names.iter().map(|n| n.as_symbol()).join(", "), id = target_commit.id() ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/undo.rs b/cli/src/commands/undo.rs index 92d1509b810..6d3d4c008f4 100644 --- a/cli/src/commands/undo.rs +++ b/cli/src/commands/undo.rs @@ -172,7 +172,8 @@ pub async fn cmd_undo( tx.finish( ui, format!("{UNDO_OP_DESC_PREFIX}{}", op_to_restore.id().hex()), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/unsign.rs b/cli/src/commands/unsign.rs index fd430395d07..a5be16d4ae5 100644 --- a/cli/src/commands/unsign.rs +++ b/cli/src/commands/unsign.rs @@ -53,7 +53,9 @@ pub async fn cmd_unsign( let target_expr = workspace_command .parse_union_revsets(ui, &args.revisions)? .resolve()?; - workspace_command.check_rewritable_expr(&target_expr)?; + workspace_command + .check_rewritable_expr(&target_expr) + .await?; let commits: IndexSet = target_expr .evaluate(workspace_command.repo().as_ref())? .stream() @@ -129,7 +131,7 @@ pub async fn cmd_unsign( commits.len() - 1 ), }; - tx.finish(ui, transaction_description)?; + tx.finish(ui, transaction_description).await?; Ok(()) } diff --git a/cli/src/commands/util/snapshot.rs b/cli/src/commands/util/snapshot.rs index fe55ed3121a..6e81c23a320 100644 --- a/cli/src/commands/util/snapshot.rs +++ b/cli/src/commands/util/snapshot.rs @@ -37,7 +37,7 @@ pub async fn cmd_util_snapshot( let mut workspace_command = command.workspace_helper_no_snapshot(ui)?; // Trigger the snapshot if needed. - let was_snapshot_taken = workspace_command.maybe_snapshot(ui)?; + let was_snapshot_taken = workspace_command.maybe_snapshot(ui).await?; if was_snapshot_taken { writeln!(ui.status(), "Snapshot complete.")?; } else { diff --git a/cli/src/commands/workspace/add.rs b/cli/src/commands/workspace/add.rs index 6997002d21c..a039f44bcaf 100644 --- a/cli/src/commands/workspace/add.rs +++ b/cli/src/commands/workspace/add.rs @@ -224,6 +224,7 @@ pub async fn cmd_workspace_add( "create initial working-copy commit in workspace {name}", name = workspace_name.as_symbol() ), - )?; + ) + .await?; Ok(()) } diff --git a/cli/src/commands/workspace/forget.rs b/cli/src/commands/workspace/forget.rs index 1a6aaa8248d..112ec27b45d 100644 --- a/cli/src/commands/workspace/forget.rs +++ b/cli/src/commands/workspace/forget.rs @@ -93,6 +93,6 @@ pub async fn cmd_workspace_forget( ) }; - tx.finish(ui, description)?; + tx.finish(ui, description).await?; Ok(()) } diff --git a/cli/src/commands/workspace/update_stale.rs b/cli/src/commands/workspace/update_stale.rs index 2a7dcfbe7c0..41fc869bf48 100644 --- a/cli/src/commands/workspace/update_stale.rs +++ b/cli/src/commands/workspace/update_stale.rs @@ -34,7 +34,7 @@ pub async fn cmd_workspace_update_stale( command: &CommandHelper, _args: &WorkspaceUpdateStaleArgs, ) -> Result<(), CommandError> { - let (workspace_command, stats) = command.recover_stale_working_copy(ui)?; + let (workspace_command, stats) = command.recover_stale_working_copy(ui).await?; print_snapshot_stats(ui, &stats, workspace_command.env().path_converter())?; Ok(()) diff --git a/cli/src/movement_util.rs b/cli/src/movement_util.rs index 049a1e5bc32..00423fe94f0 100644 --- a/cli/src/movement_util.rs +++ b/cli/src/movement_util.rs @@ -237,7 +237,7 @@ fn choose_commit<'a>( .ok_or_else(|| user_error("ambiguous target commit")) } -pub(crate) fn move_to_commit( +pub(crate) async fn move_to_commit( ui: &mut Ui, command: &CommandHelper, direction: Direction, @@ -263,18 +263,20 @@ pub(crate) fn move_to_commit( // We're editing, just move to the target commit. if args.should_edit { // We're editing, the target must be rewritable. - workspace_command.check_rewritable([target.id()])?; + workspace_command.check_rewritable([target.id()]).await?; let mut tx = workspace_command.start_transaction(); tx.edit(&target)?; tx.finish( ui, format!("{cmd}: {current_short} -> editing {target_short}"), - )?; + ) + .await?; return Ok(()); } let mut tx = workspace_command.start_transaction(); // Move the working-copy commit to the new parent. tx.check_out(&target)?; - tx.finish(ui, format!("{cmd}: {current_short} -> {target_short}"))?; + tx.finish(ui, format!("{cmd}: {current_short} -> {target_short}")) + .await?; Ok(()) }