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

Method insert_from_view

atomic-repository/src/repository/insert.rs:3453–3689  ·  view source on GitHub ↗

Insert changes from one view into another. This is the main method for cross-view operations. It can: - Insert all missing changes from source to target - Insert only changes up to a specific tag - Insert only specific changes # Arguments `options` - Options controlling the cross-view insert # Returns A `CrossViewInsertOutcome` with details about what was inserted. # Example ```rust,ignore

(
        &self,
        options: CrossViewInsertOptions,
    )

Source from the content-addressed store, hash-verified

3451 /// let result = repo.insert_from_view(options)?;
3452 /// ```
3453 pub fn insert_from_view(
3454 &self,
3455 options: CrossViewInsertOptions,
3456 ) -> Result<CrossViewInsertOutcome, RepositoryError> {
3457 let _review_boundary = if options.dry_run {
3458 None
3459 } else {
3460 self.review_evidence_lock()?
3461 };
3462 let trace_insert = std::env::var_os("ATOMIC_TRACE_INSERT").is_some();
3463 let t0 = std::time::Instant::now();
3464
3465 let mut outcome = CrossViewInsertOutcome::new();
3466 outcome.was_dry_run = options.dry_run;
3467
3468 // Determine which changes to consider
3469 let source_changes = if !options.only_changes.is_empty() {
3470 // Use only specified changes
3471 options.only_changes.clone()
3472 } else if let Some(ref tag_name) = options.up_to_tag {
3473 // Get changes up to the tag
3474 self.get_changes_up_to_tag(tag_name, Some(&options.from_view))?
3475 } else {
3476 // Get all changes from source view
3477 self.get_view_changes(Some(&options.from_view))?
3478 .into_iter()
3479 .map(|(_, hash)| hash)
3480 .collect()
3481 };
3482 let _span_lock = if self.span_in_closure(&source_changes)? {
3483 let lock = self.try_lock_workspace_operation(self.require_working_copy_id()?)?;
3484 self.preflight_span_references(
3485 &options.to_view,
3486 &source_changes,
3487 !options.apply_dependencies,
3488 )?;
3489 Some(lock)
3490 } else {
3491 None
3492 };
3493
3494 if trace_insert {
3495 eprintln!(
3496 "[insert_from_view] start from={} to={} source_changes={}",
3497 options.from_view,
3498 options.to_view,
3499 source_changes.len(),
3500 );
3501 eprintln!(
3502 "[insert_from_view] source_changes collected count={} elapsed={:?}",
3503 source_changes.len(),
3504 t0.elapsed(),
3505 );
3506 }
3507
3508 // Filter to changes not already in target
3509 let txn = self
3510 .pristine

Calls 15

filter_missing_in_viewFunction · 0.85
reachable_closureFunction · 0.85
local_did_key_providerFunction · 0.85
review_evidence_lockMethod · 0.80
get_changes_up_to_tagMethod · 0.80
get_view_changesMethod · 0.80
span_in_closureMethod · 0.80
read_txnMethod · 0.80