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

Function snapshot

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

Source from the content-addressed store, hash-verified

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