Remove an empty locally-created view whose identity conflicts with the manifest about to be applied. `Repository::init` pre-creates a shared root view (e.g. "dev"). If the remote's view of the same name is a draft or has a parent, `apply_view_manifest` would report an identity mismatch even though the local view is just an empty scaffold. Deleting the scaffold lets the manifest recreate the view
(
&self,
repo: &mut Repository,
manifest: &ViewManifest,
)
| 595 | /// Views with changes are left alone: a genuine divergence must surface |
| 596 | /// as an apply error, never a silent delete. |
| 597 | fn reconcile_scaffold_view( |
| 598 | &self, |
| 599 | repo: &mut Repository, |
| 600 | manifest: &ViewManifest, |
| 601 | ) -> CliResult<()> { |
| 602 | if !repo |
| 603 | .view_exists(&manifest.name) |
| 604 | .map_err(CliError::Repository)? |
| 605 | { |
| 606 | return Ok(()); |
| 607 | } |
| 608 | let info = repo |
| 609 | .get_view_info(&manifest.name) |
| 610 | .map_err(CliError::Repository)?; |
| 611 | if info.scope == manifest.scope && info.parent_name == manifest.parent { |
| 612 | // Identity matches; apply_view_manifest handles the log. |
| 613 | return Ok(()); |
| 614 | } |
| 615 | if info.change_count > 0 { |
| 616 | // Not a scaffold; let apply_view_manifest report the mismatch. |
| 617 | return Ok(()); |
| 618 | } |
| 619 | |
| 620 | // The scaffold may be the current view (init leaves it current), |
| 621 | // and the current view cannot be deleted — park on a temporary |
| 622 | // root view first. It is removed again before clone finishes. |
| 623 | if repo.current_view() == manifest.name { |
| 624 | if !repo |
| 625 | .view_exists(SCAFFOLD_PARK_VIEW) |
| 626 | .map_err(CliError::Repository)? |
| 627 | { |
| 628 | repo.create_shared_view(SCAFFOLD_PARK_VIEW) |
| 629 | .map_err(CliError::Repository)?; |
| 630 | } |
| 631 | repo.align_to_view(SCAFFOLD_PARK_VIEW) |
| 632 | .map_err(CliError::Repository)?; |
| 633 | } |
| 634 | |
| 635 | // Shared views cannot be deleted directly; demote first. |
| 636 | if info.scope.is_shared() { |
| 637 | repo.set_view_scope(&manifest.name, ViewScope::Draft) |
| 638 | .map_err(CliError::Repository)?; |
| 639 | } |
| 640 | repo.delete_view(&manifest.name) |
| 641 | .map_err(CliError::Repository)?; |
| 642 | Ok(()) |
| 643 | } |
| 644 | |
| 645 | /// Remove the temporary parking view, if scaffold reconciliation |
| 646 | /// created it. Best-effort: a leftover parking view is cosmetic. |
no test coverage detected