(
&self,
repo: &mut Repository,
working_copy: WorkingCopyId,
from_view: &str,
options: &SplitOptions,
confirm: F,
)
| 186 | } |
| 187 | |
| 188 | fn preview_and_prompt<F>( |
| 189 | &self, |
| 190 | repo: &mut Repository, |
| 191 | working_copy: WorkingCopyId, |
| 192 | from_view: &str, |
| 193 | options: &SplitOptions, |
| 194 | confirm: F, |
| 195 | ) -> CliResult<()> |
| 196 | where |
| 197 | F: FnOnce(&str) -> CliResult<bool>, |
| 198 | { |
| 199 | let mut preview_options = options.clone(); |
| 200 | preview_options.dry_run = true; |
| 201 | let preview = repo |
| 202 | .split_view(working_copy, preview_options) |
| 203 | .map_err(CliError::Repository)?; |
| 204 | if preview.blocked { |
| 205 | return Err(CliError::Repository( |
| 206 | atomic_repository::RepositoryError::ViewSplitHasDependents { |
| 207 | view: from_view.to_string(), |
| 208 | blocking: preview |
| 209 | .dependents |
| 210 | .iter() |
| 211 | .map(|c| c.hash.to_base32()) |
| 212 | .collect(), |
| 213 | }, |
| 214 | )); |
| 215 | } |
| 216 | print_warning(&format!( |
| 217 | "This removes {} change(s) from '{}' into draft '{}' ({} dependent change(s) included).", |
| 218 | preview.moved.len(), from_view, self.name, preview.dependents.len(), |
| 219 | )); |
| 220 | print_warning( |
| 221 | "Deleting that draft without inserting its changes elsewhere may leave them orphaned, invisible in every view. They will not return to the source automatically.", |
| 222 | ); |
| 223 | let prompt = format!( |
| 224 | "Split {} change(s) from '{}' into '{}'? I understand deleting the draft may orphan them", |
| 225 | preview.moved.len(), from_view, self.name, |
| 226 | ); |
| 227 | if !confirm(&prompt)? { |
| 228 | return Err(CliError::Cancelled); |
| 229 | } |
| 230 | Ok(()) |
| 231 | } |
| 232 | |
| 233 | fn execute_with_repo_gated<F>( |
| 234 | &self, |
no test coverage detected