MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / run_single_insert

Function run_single_insert

atomic-cli/src/commands/insert.rs:218–262  ·  view source on GitHub ↗

Insert a single change by hash.

(repo: &Repository, change_str: &str, args: &Insert)

Source from the content-addressed store, hash-verified

216
217/// Insert a single change by hash.
218fn run_single_insert(repo: &Repository, change_str: &str, args: &Insert) -> CliResult<()> {
219 let hash = parse_change_hash(repo, change_str)?;
220 let is_current_view = args.view.is_none() || args.view.as_deref() == Some(repo.current_view());
221
222 let options = InsertOptions::default()
223 .apply_deps(args.deps)
224 .allow_conflict(args.allow_conflicts);
225
226 let options = if let Some(ref view) = args.view {
227 options.view(view)
228 } else {
229 options
230 };
231
232 output::print_info(&format!("Inserting change {}...", format_hash(&hash, true)));
233
234 let outcome = if args.deps {
235 repo.insert_change_rec(&hash, options)
236 } else {
237 repo.insert_change(&hash, options)
238 }
239 .map_err(|e| CliError::Conflict {
240 description: e.to_string(),
241 })?;
242
243 print_insert_outcome(
244 &outcome.stats.applied_hashes,
245 outcome.new_state,
246 outcome.has_conflicts,
247 );
248
249 // Update working copy if we inserted into the current view
250 if is_current_view && !outcome.stats.applied_hashes.is_empty() {
251 let output_result = repo.materialize().map_err(|e| {
252 CliError::Internal(anyhow::anyhow!("Failed to update working copy: {}", e))
253 })?;
254 output::print_success(&format!(
255 "{} files updated, {} directories",
256 output_result.files_written, output_result.directories_created
257 ));
258 print_conflict_summary(repo);
259 }
260
261 Ok(())
262}
263
264/// Promote the current view's changes into its parent view.
265///

Callers 1

runMethod · 0.85

Calls 14

print_infoFunction · 0.85
print_insert_outcomeFunction · 0.85
print_successFunction · 0.85
print_conflict_summaryFunction · 0.85
is_noneMethod · 0.80
current_viewMethod · 0.80
allow_conflictMethod · 0.80
apply_depsMethod · 0.80
insert_change_recMethod · 0.80
materializeMethod · 0.80
parse_change_hashFunction · 0.70
viewMethod · 0.45

Tested by

no test coverage detected