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,
)
| 3401 | /// let result = repo.insert_from_view(options)?; |
| 3402 | /// ``` |
| 3403 | pub fn insert_from_view( |
| 3404 | &self, |
| 3405 | options: CrossViewInsertOptions, |
| 3406 | ) -> Result<CrossViewInsertOutcome, RepositoryError> { |
| 3407 | let trace_insert = std::env::var_os("ATOMIC_TRACE_INSERT").is_some(); |
| 3408 | let t0 = std::time::Instant::now(); |
| 3409 | |
| 3410 | let mut outcome = CrossViewInsertOutcome::new(); |
| 3411 | outcome.was_dry_run = options.dry_run; |
| 3412 | |
| 3413 | // Determine which changes to consider |
| 3414 | let source_changes = if !options.only_changes.is_empty() { |
| 3415 | // Use only specified changes |
| 3416 | options.only_changes.clone() |
| 3417 | } else if let Some(ref tag_name) = options.up_to_tag { |
| 3418 | // Get changes up to the tag |
| 3419 | self.get_changes_up_to_tag(tag_name, Some(&options.from_view))? |
| 3420 | } else { |
| 3421 | // Get all changes from source view |
| 3422 | self.get_view_changes(Some(&options.from_view))? |
| 3423 | .into_iter() |
| 3424 | .map(|(_, hash)| hash) |
| 3425 | .collect() |
| 3426 | }; |
| 3427 | let _span_lock = if self.span_in_closure(&source_changes)? { |
| 3428 | let lock = self.try_lock_workspace_operation(self.require_working_copy_id()?)?; |
| 3429 | self.preflight_span_references( |
| 3430 | &options.to_view, |
| 3431 | &source_changes, |
| 3432 | !options.apply_dependencies, |
| 3433 | )?; |
| 3434 | Some(lock) |
| 3435 | } else { |
| 3436 | None |
| 3437 | }; |
| 3438 | |
| 3439 | if trace_insert { |
| 3440 | eprintln!( |
| 3441 | "[insert_from_view] start from={} to={} source_changes={}", |
| 3442 | options.from_view, |
| 3443 | options.to_view, |
| 3444 | source_changes.len(), |
| 3445 | ); |
| 3446 | eprintln!( |
| 3447 | "[insert_from_view] source_changes collected count={} elapsed={:?}", |
| 3448 | source_changes.len(), |
| 3449 | t0.elapsed(), |
| 3450 | ); |
| 3451 | } |
| 3452 | |
| 3453 | // Filter to changes not already in target |
| 3454 | let txn = self |
| 3455 | .pristine |
| 3456 | .read_txn() |
| 3457 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 3458 | |
| 3459 | let to_view = txn |
| 3460 | .get_view(&options.to_view) |