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

Function snapshot

atomic-repository/tests/span_insert.rs:669–714  ·  view source on GitHub ↗
(
    repo: &Repository,
)

Source from the content-addressed store, hash-verified

667}
668
669fn snapshot(
670 repo: &Repository,
671) -> (
672 Merkle,
673 u64,
674 Vec<OperationId>,
675 Vec<OperationId>,
676 Vec<OperationId>,
677 usize,
678) {
679 let txn = repo.pristine().read_txn().unwrap();
680 let view = txn.get_view("target").unwrap().unwrap();
681 let mut operations: Vec<_> = txn
682 .list_operations()
683 .unwrap()
684 .iter()
685 .map(|op| op.id())
686 .collect();
687 operations.sort();
688 let receipts = operations
689 .iter()
690 .map(|id| txn.get_effect_receipts(*id).unwrap().len())
691 .sum();
692 let mut heads = txn
693 .get_operation_heads(OperationScope::Repository)
694 .unwrap()
695 .as_slice()
696 .to_vec();
697 heads.sort();
698 let mut wc_heads = txn
699 .get_operation_heads(OperationScope::WorkingCopy(
700 repo.require_working_copy_id().unwrap(),
701 ))
702 .unwrap()
703 .as_slice()
704 .to_vec();
705 wc_heads.sort();
706 (
707 view.state,
708 view.change_count,
709 operations,
710 heads,
711 wc_heads,
712 receipts,
713 )
714}
715
716fn fixture() -> (tempfile::TempDir, Repository, Hash, Hash) {
717 let dir = tempfile::tempdir().unwrap();

Calls 15

WorkingCopyInterface · 0.85
read_txnMethod · 0.80
pristineMethod · 0.80
sortMethod · 0.80
unwrapMethod · 0.45
get_viewMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45
list_operationsMethod · 0.45
idMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected