(&self)
| 154 | |
| 155 | impl Command for Split { |
| 156 | fn run(&self) -> CliResult<()> { |
| 157 | // Validate the new view name |
| 158 | validate_view_name(&self.name).map_err(|msg| CliError::InvalidArgument { message: msg })?; |
| 159 | |
| 160 | // Find the repository |
| 161 | let repo_root = find_repository_root()?; |
| 162 | let mut repo = Repository::open(&repo_root).map_err(|e| match e { |
| 163 | atomic_repository::RepositoryError::NotFound { path } => CliError::RepositoryNotFound { |
| 164 | searched_path: path.into(), |
| 165 | }, |
| 166 | other => CliError::Repository(other), |
| 167 | })?; |
| 168 | |
| 169 | // Determine source view (default to current) |
| 170 | let source = self |
| 171 | .source |
| 172 | .clone() |
| 173 | .unwrap_or_else(|| repo.current_view().to_string()); |
| 174 | |
| 175 | // Verify source view exists |
| 176 | if !repo.view_exists(&source).map_err(CliError::Repository)? { |
| 177 | return Err(CliError::ViewNotFound { |
| 178 | name: source.clone(), |
| 179 | }); |
| 180 | } |
| 181 | |
| 182 | // Check if the new view already exists |
| 183 | if repo.view_exists(&self.name).map_err(CliError::Repository)? { |
| 184 | return Err(CliError::ViewAlreadyExists { |
| 185 | name: self.name.clone(), |
| 186 | }); |
| 187 | } |
| 188 | |
| 189 | // Get source view info for reporting |
| 190 | let source_info = repo.get_view_info(&source).map_err(CliError::Repository)?; |
| 191 | let change_count = source_info.change_count; |
| 192 | |
| 193 | // Create the new view by copying change log from source. |
| 194 | // This does NOT re-insert changes into the graph - it just copies metadata. |
| 195 | // This avoids conflicts that would occur if we tried to re-insert changes |
| 196 | // that have already modified the shared graph. |
| 197 | repo.create_view_from(&self.name, &source) |
| 198 | .map_err(CliError::Repository)?; |
| 199 | |
| 200 | if change_count > 0 { |
| 201 | print_success(&format!( |
| 202 | "Created view: {} (split from {} with {} changes)", |
| 203 | style_view(&self.name), |
| 204 | style_view(&source), |
| 205 | change_count |
| 206 | )); |
| 207 | } else { |
| 208 | print_success(&format!( |
| 209 | "Created view: {} (split from {} - empty)", |
| 210 | style_view(&self.name), |
| 211 | style_view(&source) |
| 212 | )); |
| 213 | } |
nothing calls this directly
no test coverage detected