Enhanced Historical Functionality for All Storage Types and Complex Multi-Branch Testing #81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements comprehensive historical functionality for all storage types (InMemory, File, RocksDB) by ensuring they
save tree configuration to git commits, and adds extensive multi-branch testing for the get_commits method. A critical bug in
branch isolation was also discovered and fixed during testing.
Key Changes
Problem: Only GitNodeStorage had full historical functionality. Other storage types (InMemory, File, RocksDB) couldn't
provide historical access because they didn't save tree configuration to git commits.
Solution:
Impact: All storage types now support full historical functionality:
Problem: Critical bug discovered during testing - when switching branches, data would leak between branches. Keys created on
feature branches would appear on main branch.
Solution:
Impact: Perfect branch isolation - keys are now properly scoped to their respective branches.
Added 4 new test suites covering complex real-world scenarios:
test_get_commits_complex_multi_branch_scenarios
test_get_commits_merge_scenarios
test_get_commits_key_lifecycle_patterns
test_get_commits_empty_and_edge_cases
Test Results
Example Usage
// Now works for ALL storage types (not just Git)
let mut store = InMemoryVersionedKvStore::<32>::init(&path)?;
// Add data and commit
store.insert(b"key1".to_vec(), b"value1".to_vec()).unwrap();
let commit1 = store.commit("Add key1").unwrap();
// Create feature branch and modify key
store.create_branch("feature/enhancement").unwrap();
store.checkout("feature/enhancement").unwrap();
store.update(b"key1".to_vec(), b"new_value".to_vec()).unwrap();
let commit2 = store.commit("Update key1 on feature").unwrap();
// Historical access now works for all storage types
let commits = store.get_commits(b"key1").unwrap(); // Returns 2 commits
let diff = store.diff(&commit1.to_hex().to_string(), &commit2.to_hex().to_string()).unwrap();
let keys_at_head = store.get_keys_at_ref("HEAD").unwrap();
// Branch isolation - switching back to main
store.checkout("main").unwrap();
let main_commits = store.get_commits(b"key1").unwrap(); // Returns 1 commit (no feature changes)