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

Method plan_restore_ignored_paths

atomic-repository/src/repository/switch.rs:1544–1595  ·  view source on GitHub ↗

Plan the collision-safe restore of `new_view`'s shelved artifacts into the working copy. A destination occupied by unexplained content is a typed refusal, never an overwrite.

(
        &self,
        working_copy: WorkingCopyId,
        new_view: &str,
        path: &str,
        effects: &mut Vec<EffectPlan>,
    )

Source from the content-addressed store, hash-verified

1542 /// the working copy. A destination occupied by unexplained content is a
1543 /// typed refusal, never an overwrite.
1544 pub(super) fn plan_restore_ignored_paths(
1545 &self,
1546 working_copy: WorkingCopyId,
1547 new_view: &str,
1548 path: &str,
1549 effects: &mut Vec<EffectPlan>,
1550 ) -> Result<(), RepositoryError> {
1551 let shelf = EffectTarget::ShelfPath {
1552 working_copy,
1553 view: new_view.to_string(),
1554 path: path.to_string(),
1555 };
1556 let shelf_old = effects
1557 .iter()
1558 .rev()
1559 .find(|effect| effect.target == shelf)
1560 .map(|effect| effect.expected_new.clone())
1561 .unwrap_or(self.observe_filesystem_effect(working_copy, &shelf)?);
1562 if shelf_old == EffectValue::Absent {
1563 return Ok(());
1564 }
1565 let destination = EffectTarget::WorkspacePath {
1566 working_copy,
1567 path: path.to_string(),
1568 };
1569 let destination_old = effects
1570 .iter()
1571 .rev()
1572 .find(|effect| effect.target == destination)
1573 .map(|effect| effect.expected_new.clone())
1574 .unwrap_or(self.observe_filesystem_effect(working_copy, &destination)?);
1575 if destination_old != EffectValue::Absent {
1576 return Err(RepositoryError::InvalidOperation {
1577 message: format!(
1578 "cannot restore shelf path '{path}': working-copy destination has unexplained content"
1579 ),
1580 });
1581 }
1582 effects.push(EffectPlan {
1583 ordinal: effects.len() as u32,
1584 target: shelf,
1585 expected_old: shelf_old.clone(),
1586 expected_new: EffectValue::Absent,
1587 });
1588 effects.push(EffectPlan {
1589 ordinal: effects.len() as u32,
1590 target: destination,
1591 expected_old: EffectValue::Absent,
1592 expected_new: shelf_old,
1593 });
1594 Ok(())
1595 }
1596
1597 /// Ignored-path candidates for the shelf planner, excluding graph-tracked
1598 /// paths and `[workspace] expose` policy paths.

Callers 2

switch_view_journaledMethod · 0.80

Calls 5

iterMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected