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

Function run_single_insert

atomic-cli/src/commands/insert.rs:194–237  ·  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

192
193/// Insert a single change by hash.
194fn run_single_insert(repo: &Repository, change_str: &str, args: &Insert) -> CliResult<()> {
195 let hash = parse_change_hash(repo, change_str)?;
196 let is_current_view = args.view.is_none() || args.view.as_deref() == Some(repo.current_view());
197
198 let options = InsertOptions::default()
199 .apply_deps(args.deps)
200 .allow_conflict(args.allow_conflicts);
201
202 let options = if let Some(ref view) = args.view {
203 options.view(view)
204 } else {
205 options
206 };
207
208 output::print_info(&format!("Inserting change {}...", format_hash(&hash, true)));
209
210 let outcome = if args.deps {
211 repo.insert_change_rec(&hash, options)
212 } else {
213 repo.insert_change(&hash, options)
214 }
215 .map_err(|e| CliError::Conflict {
216 description: e.to_string(),
217 })?;
218
219 print_insert_outcome(
220 &outcome.stats.applied_hashes,
221 outcome.new_state,
222 outcome.has_conflicts,
223 );
224
225 // Update working copy if we inserted into the current view
226 if is_current_view && !outcome.stats.applied_hashes.is_empty() {
227 let output_result = repo.materialize().map_err(|e| {
228 CliError::Internal(anyhow::anyhow!("Failed to update working copy: {}", e))
229 })?;
230 output::print_success(&format!(
231 "{} files updated, {} directories",
232 output_result.files_written, output_result.directories_created
233 ));
234 }
235
236 Ok(())
237}
238
239/// Insert changes from one view to another.
240fn run_from_view(repo: &Repository, args: &FromViewArgs) -> CliResult<()> {

Callers 1

runMethod · 0.85

Calls 13

parse_change_hashFunction · 0.85
print_infoFunction · 0.85
print_insert_outcomeFunction · 0.85
print_successFunction · 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
viewMethod · 0.45
insert_changeMethod · 0.45

Tested by

no test coverage detected