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

Method validate_serialized_name_conflict

atomic-core/src/change/graph_op.rs:468–512  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

466
467impl GraphOp<Option<Hash>> {
468 pub(crate) fn validate_serialized_name_conflict(&self) -> Result<(), String> {
469 if let GraphOp::SetAttr { inode, path, value } = self {
470 if path.is_empty() {
471 return Err("SetAttr requires a non-empty path".to_string());
472 }
473 if inode.change == Some(Hash::NONE) {
474 return Err("SetAttr cannot target ROOT".to_string());
475 }
476 value.validate().map_err(|error| error.to_string())?;
477 }
478 self.validate_name_conflict()?;
479 let (operation, name) = match self {
480 GraphOp::SolveNameConflict { name, .. } => ("SolveNameConflict", name),
481 GraphOp::UnsolveNameConflict { name, .. } => ("UnsolveNameConflict", name),
482 _ => return Ok(()),
483 };
484
485 validate_explicit_name_conflict_hash(
486 operation,
487 "surviving claimant",
488 name.inode.change,
489 false,
490 )?;
491 for (index, edge) in name.edges.iter().enumerate() {
492 validate_explicit_name_conflict_hash(
493 operation,
494 &format!("edge {index} source"),
495 edge.from.change,
496 true,
497 )?;
498 validate_explicit_name_conflict_hash(
499 operation,
500 &format!("edge {index} target"),
501 edge.to.change,
502 false,
503 )?;
504 validate_explicit_name_conflict_hash(
505 operation,
506 &format!("edge {index} introducer"),
507 edge.introduced_by,
508 false,
509 )?;
510 }
511 Ok(())
512 }
513}
514
515fn validate_explicit_name_conflict_hash(

Callers

nothing calls this directly

Calls 5

is_emptyMethod · 0.45
validateMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected