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

Function metadata

atomic-core/src/pristine/span_patch_storage/legacy.rs:68–114  ·  view source on GitHub ↗
(hash: Hash, change: &Change)

Source from the content-addressed store, hash-verified

66}
67
68pub(super) fn metadata(hash: Hash, change: &Change) -> LegacyMetadata {
69 let mut result = LegacyMetadata::default();
70 for ops in change.file_ops() {
71 if let Some(crate::crdt::TrunkOp::ProjectedSpanEdit { file, .. }) = ops.trunk_op() {
72 result.projected_files.push(file.clone());
73 }
74 if change.hashed.span.is_none() && !ops.trunk_id().change_id().is_root() {
75 for op in change
76 .hunks()
77 .iter()
78 .filter(|op| op.path() == Some(ops.path()))
79 {
80 for atom in op.atoms() {
81 let inode = match atom {
82 AtomRef::Insertion(i) | AtomRef::Atom(Atom::Insertion(i)) => i.inode,
83 AtomRef::EdgeUpdate(e) | AtomRef::Atom(Atom::EdgeUpdate(e)) => e.inode,
84 };
85 result.foreign_trunks.push((
86 inode.change.unwrap_or(hash),
87 inode.pos.get(),
88 ops.trunk_id().change_id().get(),
89 ));
90 }
91 }
92 }
93 }
94 for op in change.hunks() {
95 if let GraphOp::FileAdd { add_inode, .. } = op {
96 let pos = add_inode.start.get();
97 result.files.push(pos);
98 result.ranges.insert((hash, pos, pos, pos));
99 }
100 for atom in op.atoms() {
101 if let AtomRef::Insertion(insert) | AtomRef::Atom(Atom::Insertion(insert)) = atom {
102 if !insert.flag.contains(crate::EdgeFlags::FOLDER) && insert.start < insert.end {
103 result.ranges.insert((
104 insert.inode.change.unwrap_or(hash),
105 insert.inode.pos.get(),
106 insert.start.get(),
107 insert.end.get(),
108 ));
109 }
110 }
111 }
112 }
113 result
114}
115
116pub(super) fn retrieve<T: GraphTxnT + super::super::TreeTxnT>(
117 txn: &T,

Calls 15

is_noneMethod · 0.80
atomsMethod · 0.80
getMethod · 0.65
file_opsMethod · 0.45
trunk_opMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45
is_rootMethod · 0.45
change_idMethod · 0.45
trunk_idMethod · 0.45
iterMethod · 0.45
hunksMethod · 0.45