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

Function plan_view_sync

libatomic/src/daemon/services_sync_remote.rs:303–344  ·  view source on GitHub ↗
(
    local: &ViewManifest,
    remote: Option<&ViewManifest>,
)

Source from the content-addressed store, hash-verified

301}
302
303fn plan_view_sync(
304 local: &ViewManifest,
305 remote: Option<&ViewManifest>,
306) -> Result<ViewSyncPlan, ViewSyncConflict> {
307 let Some(remote) = remote else {
308 return Ok(ViewSyncPlan {
309 suffix: local.changes.clone(),
310 declare: true,
311 forced: false,
312 shrink: false,
313 });
314 };
315 if remote.scope != local.scope {
316 return Err(ViewSyncConflict::IdentityMismatch {
317 field: "scope",
318 local: local.scope.to_string(),
319 remote: remote.scope.to_string(),
320 });
321 }
322 if remote.parent != local.parent {
323 let show = |parent: &Option<String>| parent.clone().unwrap_or_else(|| "(none)".to_string());
324 return Err(ViewSyncConflict::IdentityMismatch {
325 field: "parent",
326 local: show(&local.parent),
327 remote: show(&remote.parent),
328 });
329 }
330 let remote_set: HashSet<Hash> = remote.changes.iter().copied().collect();
331 let local_set: HashSet<Hash> = local.changes.iter().copied().collect();
332 let suffix = local
333 .changes
334 .iter()
335 .filter(|hash| !remote_set.contains(hash))
336 .copied()
337 .collect();
338 Ok(ViewSyncPlan {
339 suffix,
340 declare: !local_set.is_subset(&remote_set),
341 forced: false,
342 shrink: false,
343 })
344}
345
346/// The local `mint_view_snapshot` — the content-addressed snapshot mint
347/// (the own-set-id fold matches the server bridge).

Callers 1

push_changes_implFunction · 0.70

Calls 4

cloneMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected