Resolve the `(source, target)` view pair a triage run operates on. Both arguments are optional so the common gesture needs no arguments at all: the source is the current view and the target is that view's direct parent — the same default `atomic insert` uses for a bare promote. `arg` names the argument a name came from so an unknown view can be reported against it. # Errors Returns [`CliError::
(
repo: &Repository,
feature: Option<&str>,
into: Option<&str>,
)
| 277 | /// exist, or if the target was omitted and the source is a root view (nothing |
| 278 | /// to promote into). |
| 279 | fn resolve_views( |
| 280 | repo: &Repository, |
| 281 | feature: Option<&str>, |
| 282 | into: Option<&str>, |
| 283 | ) -> CliResult<(String, String)> { |
| 284 | let source = match feature { |
| 285 | Some(name) => { |
| 286 | require_view(repo, name, "<VIEW>")?; |
| 287 | name.to_string() |
| 288 | } |
| 289 | None => repo.current_view().to_string(), |
| 290 | }; |
| 291 | |
| 292 | let target = match into { |
| 293 | Some(name) => { |
| 294 | require_view(repo, name, "--into")?; |
| 295 | name.to_string() |
| 296 | } |
| 297 | None => match repo.parent_change_count(&source) { |
| 298 | Ok(Some((parent, _))) => parent, |
| 299 | Ok(None) => { |
| 300 | return Err(CliError::InvalidArgument { |
| 301 | message: format!( |
| 302 | "'{source}' is a root view — it has no parent to promote into.\n \ |
| 303 | Pass --into <view> to choose a target (see 'atomic view list')." |
| 304 | ), |
| 305 | }) |
| 306 | } |
| 307 | Err(RepositoryError::ViewNotFound { name }) => { |
| 308 | return Err(unknown_view(repo, &name, "<VIEW>")) |
| 309 | } |
| 310 | Err(e) => return Err(CliError::Repository(e)), |
| 311 | }, |
| 312 | }; |
| 313 | |
| 314 | Ok((source, target)) |
| 315 | } |
| 316 | |
| 317 | /// Fail with an actionable message when a triage view argument names a view |
| 318 | /// that does not exist. |