The bare `atomic insert` promotion over InsertChanges — the promote arm resolves the current view, its parent, and the missing set server-side (the CLI holds no repository handle). The dry-run form renders the local preview from the pre-flight response; the real form pre-flights, runs the shared→shared confirmation client-side, then inserts through the same arm. Rendered with the local body's exac
(args: &super::insert::Insert)
| 4194 | /// inserts through the same arm. Rendered with the local body's exact |
| 4195 | /// print functions. |
| 4196 | pub fn insert_promote(args: &super::insert::Insert) -> CliResult<bool> { |
| 4197 | let Some(session) = Service::open()? else { |
| 4198 | return Ok(false); |
| 4199 | }; |
| 4200 | let mut request = insert_request( |
| 4201 | &session, |
| 4202 | Some(pb::insert_changes_request::Source::PromoteCurrentView( |
| 4203 | pb::PromoteCurrentView {}, |
| 4204 | )), |
| 4205 | args.view.clone(), |
| 4206 | args.allow_conflicts, |
| 4207 | args.deps, |
| 4208 | true, |
| 4209 | ); |
| 4210 | // The pre-flight read: source, parent, the missing set, and the |
| 4211 | // confirm-gate scopes — the same domain reads the local pre-flight |
| 4212 | // makes. The request is kept for the insert phase (the same arm |
| 4213 | // without the preview flag). |
| 4214 | let response = insert_rpc(&session, request.clone())?; |
| 4215 | let source = response.resolved_source_view.clone().unwrap_or_default(); |
| 4216 | let target = response.resolved_target_view.clone().unwrap_or_default(); |
| 4217 | let missing = response.inserted.len(); |
| 4218 | if missing == 0 { |
| 4219 | print_success(&format!( |
| 4220 | "Already even with '{target}' — nothing to insert." |
| 4221 | )); |
| 4222 | return Ok(true); |
| 4223 | } |
| 4224 | print_info(&format!( |
| 4225 | "Inserting {missing} change(s): {source} → {target}" |
| 4226 | )); |
| 4227 | if args.dry_run { |
| 4228 | // The local dry-run branch: the numbered missing list (full hash |
| 4229 | // plus the 50-byte-truncated message), then the dry-run notice. |
| 4230 | println!(); |
| 4231 | for (i, change) in response.inserted.iter().enumerate() { |
| 4232 | let hash = short_hash_full(&change.hash); |
| 4233 | match change.message.as_deref() { |
| 4234 | Some(message) if !message.is_empty() => println!( |
| 4235 | " {}. {} {}", |
| 4236 | i + 1, |
| 4237 | hash, |
| 4238 | crate::output::truncate_bytes(message, 50) |
| 4239 | ), |
| 4240 | _ => println!(" {}. {}", i + 1, hash), |
| 4241 | } |
| 4242 | } |
| 4243 | println!(); |
| 4244 | print_info("Dry run: no changes inserted. Re-run without --dry-run to insert."); |
| 4245 | return Ok(true); |
| 4246 | } |
| 4247 | // The shared→shared gate: the prompt runs client-side (interactive); |
| 4248 | // the wire carries the scopes the local pre-flight reads. |
| 4249 | if response.both_views_shared.unwrap_or(false) && !args.confirm { |
| 4250 | let prompt = format!( |
| 4251 | "Insert {missing} change(s) from shared view '{source}' into shared view '{target}'?" |
| 4252 | ); |
| 4253 | let confirmed = dialoguer::Confirm::new() |
no test coverage detected