@@ -454,7 +454,8 @@ impl CommandHelper {
454454 ) -> Result < ( WorkspaceCommandHelper , SnapshotStats ) , CommandError > {
455455 let mut workspace_command = self . workspace_helper_no_snapshot ( ui) ?;
456456
457- let ( workspace_command, stats) = match workspace_command. maybe_snapshot_impl ( ui) {
457+ let ( workspace_command, stats) = match workspace_command. maybe_snapshot_impl ( ui) . block_on ( )
458+ {
458459 Ok ( stats) => ( workspace_command, stats) ,
459460 Err ( SnapshotWorkingCopyError :: Command ( err) ) => return Err ( err) ,
460461 Err ( SnapshotWorkingCopyError :: StaleWorkingCopy ( err) ) => {
@@ -633,6 +634,7 @@ impl CommandHelper {
633634 // should be no data loss at least.
634635 let fresh_stats = workspace_command
635636 . maybe_snapshot_impl ( ui)
637+ . await
636638 . map_err ( |err| err. into_command_error ( ) ) ?;
637639 let merged_stats = {
638640 let SnapshotStats {
@@ -1179,7 +1181,10 @@ impl WorkspaceCommandHelper {
11791181 /// call [`print_snapshot_stats`] with the [`SnapshotStats`] returned by
11801182 /// this function to present possible untracked files to the user.
11811183 #[ instrument( skip_all) ]
1182- fn maybe_snapshot_impl ( & mut self , ui : & Ui ) -> Result < SnapshotStats , SnapshotWorkingCopyError > {
1184+ async fn maybe_snapshot_impl (
1185+ & mut self ,
1186+ ui : & Ui ,
1187+ ) -> Result < SnapshotStats , SnapshotWorkingCopyError > {
11831188 if !self . may_update_working_copy {
11841189 return Ok ( SnapshotStats :: default ( ) ) ;
11851190 }
@@ -1199,7 +1204,7 @@ impl WorkspaceCommandHelper {
11991204 let op_heads_store = repo. loader ( ) . op_heads_store ( ) ;
12001205 let op_heads = op_heads_store
12011206 . get_op_heads ( )
1202- . block_on ( )
1207+ . await
12031208 . map_err ( snapshot_command_error) ?;
12041209 if std:: slice:: from_ref ( repo. op_id ( ) ) != op_heads {
12051210 let op = self
@@ -1210,7 +1215,7 @@ impl WorkspaceCommandHelper {
12101215 let current_repo = repo
12111216 . loader ( )
12121217 . load_at ( & op)
1213- . block_on ( )
1218+ . await
12141219 . map_err ( snapshot_command_error) ?;
12151220 self . user_repo = ReadonlyUserRepo :: new ( current_repo) ;
12161221 }
@@ -1219,20 +1224,20 @@ impl WorkspaceCommandHelper {
12191224 #[ cfg( feature = "git" ) ]
12201225 if self . working_copy_shared_with_git {
12211226 self . import_git_head ( ui, & git_import_export_lock)
1222- . block_on ( )
1227+ . await
12231228 . map_err ( snapshot_command_error) ?;
12241229 }
12251230 // Because the Git refs (except HEAD) aren't imported yet, the ref
12261231 // pointing to the new working-copy commit might not be exported.
12271232 // In that situation, the ref would be conflicted anyway, so export
12281233 // failure is okay.
1229- let stats = self . snapshot_working_copy ( ui) . block_on ( ) ?;
1234+ let stats = self . snapshot_working_copy ( ui) . await ?;
12301235
12311236 // import_git_refs() can rebase the working-copy commit.
12321237 #[ cfg( feature = "git" ) ]
12331238 if self . working_copy_shared_with_git {
12341239 self . import_git_refs ( ui, & git_import_export_lock)
1235- . block_on ( )
1240+ . await
12361241 . map_err ( snapshot_command_error) ?;
12371242 }
12381243 Ok ( stats)
@@ -1243,10 +1248,11 @@ impl WorkspaceCommandHelper {
12431248 ///
12441249 /// Returns whether a snapshot was taken.
12451250 #[ instrument( skip_all) ]
1246- pub fn maybe_snapshot ( & mut self , ui : & Ui ) -> Result < bool , CommandError > {
1251+ pub async fn maybe_snapshot ( & mut self , ui : & Ui ) -> Result < bool , CommandError > {
12471252 let op_id_before = self . repo ( ) . op_id ( ) . clone ( ) ;
12481253 let stats = self
12491254 . maybe_snapshot_impl ( ui)
1255+ . await
12501256 . map_err ( |err| err. into_command_error ( ) ) ?;
12511257 print_snapshot_stats ( ui, & stats, self . env ( ) . path_converter ( ) ) ?;
12521258 let op_id_after = self . repo ( ) . op_id ( ) ;
@@ -1433,6 +1439,7 @@ to the current parents may contain changes from multiple commits.
14331439 self . user_repo = ReadonlyUserRepo :: new ( repo) ;
14341440
14351441 self . maybe_snapshot_impl ( ui)
1442+ . await
14361443 . map_err ( |err| err. into_command_error ( ) )
14371444 }
14381445
0 commit comments