Two-tier view creation: --draft and/or --parent.
(
&self,
name: &str,
repo: &mut Repository,
working_copy: atomic_core::WorkingCopyId,
workspace_view: &str,
)
| 257 | |
| 258 | /// Two-tier view creation: --draft and/or --parent. |
| 259 | fn run_two_tier( |
| 260 | &self, |
| 261 | name: &str, |
| 262 | repo: &mut Repository, |
| 263 | working_copy: atomic_core::WorkingCopyId, |
| 264 | workspace_view: &str, |
| 265 | ) -> CliResult<bool> { |
| 266 | let kind = if self.draft { |
| 267 | ViewScope::Draft |
| 268 | } else { |
| 269 | ViewScope::Shared |
| 270 | }; |
| 271 | let parent_name = self.parent.as_deref().unwrap_or(workspace_view); |
| 272 | |
| 273 | repo.create_view_with_identity(name, kind, Some(parent_name)) |
| 274 | .map_err(CliError::Repository)?; |
| 275 | |
| 276 | let kind_label = if kind.is_draft() { "draft" } else { "shared" }; |
| 277 | |
| 278 | print_success(&format!( |
| 279 | "Created {} view: {} (parent: {})", |
| 280 | kind_label, |
| 281 | style_view(name), |
| 282 | style_view(parent_name), |
| 283 | )); |
| 284 | |
| 285 | if self.switch { |
| 286 | let result = repo |
| 287 | .switch_view(working_copy, name) |
| 288 | .map_err(CliError::Repository)?; |
| 289 | print_success(&format!( |
| 290 | "Switched to view: {} ({} files updated)", |
| 291 | style_view(name), |
| 292 | result.files_written, |
| 293 | )); |
| 294 | let repo_root = find_repository_root()?; |
| 295 | if crate::commands::git::shadow::shim_publication_required(&repo_root) { |
| 296 | let shadow_sync = |
| 297 | crate::commands::git::shadow::sync_git_head_to_view(repo, &repo_root, name)?; |
| 298 | drop(shadow_sync); |
| 299 | // The projected switch moved Git HEAD; the checkpoint |
| 300 | // verifier takes its own redb lock, so the caller refreshes |
| 301 | // it after releasing this repository handle. |
| 302 | return Ok(true); |
| 303 | } |
| 304 | } |
| 305 | Ok(false) |
| 306 | } |
| 307 | |
| 308 | /// Optionally switch to the new view and print hint. |
| 309 | /// |
nothing calls this directly
no test coverage detected