Mercurial > hg
comparison rust/hg-core/src/revlog/changelog.rs @ 51867:69b804c8e09e
rust: use new revlog configs in all revlog opening code
This centralizes the more complex logic needed for the upcoming code
and creates stronger APIs with fewer booleans.
We also reuse `RevlogType` where needed.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Wed, 19 Jun 2024 12:49:26 +0200 |
parents | bbe59cc5d2e1 |
children | db7dbe6f7bb2 |
comparison
equal
deleted
inserted
replaced
51866:09ece563609a | 51867:69b804c8e09e |
---|---|
499 | 499 |
500 #[cfg(test)] | 500 #[cfg(test)] |
501 mod tests { | 501 mod tests { |
502 use super::*; | 502 use super::*; |
503 use crate::vfs::Vfs; | 503 use crate::vfs::Vfs; |
504 use crate::NULL_REVISION; | 504 use crate::{ |
505 RevlogDataConfig, RevlogDeltaConfig, RevlogFeatureConfig, | |
506 NULL_REVISION, | |
507 }; | |
505 use pretty_assertions::assert_eq; | 508 use pretty_assertions::assert_eq; |
506 | 509 |
507 #[test] | 510 #[test] |
508 fn test_create_changelogrevisiondata_invalid() { | 511 fn test_create_changelogrevisiondata_invalid() { |
509 // Completely empty | 512 // Completely empty |
560 fn test_data_from_rev_null() -> Result<(), RevlogError> { | 563 fn test_data_from_rev_null() -> Result<(), RevlogError> { |
561 // an empty revlog will be enough for this case | 564 // an empty revlog will be enough for this case |
562 let temp = tempfile::tempdir().unwrap(); | 565 let temp = tempfile::tempdir().unwrap(); |
563 let vfs = Vfs { base: temp.path() }; | 566 let vfs = Vfs { base: temp.path() }; |
564 std::fs::write(temp.path().join("foo.i"), b"").unwrap(); | 567 std::fs::write(temp.path().join("foo.i"), b"").unwrap(); |
565 let revlog = | 568 std::fs::write(temp.path().join("foo.d"), b"").unwrap(); |
566 Revlog::open(&vfs, "foo.i", None, RevlogOpenOptions::new()) | 569 let revlog = Revlog::open( |
567 .unwrap(); | 570 &vfs, |
571 "foo.i", | |
572 None, | |
573 RevlogOpenOptions::new( | |
574 false, | |
575 RevlogDataConfig::default(), | |
576 RevlogDeltaConfig::default(), | |
577 RevlogFeatureConfig::default(), | |
578 ), | |
579 ) | |
580 .unwrap(); | |
568 | 581 |
569 let changelog = Changelog { revlog }; | 582 let changelog = Changelog { revlog }; |
570 assert_eq!( | 583 assert_eq!( |
571 changelog.data_for_rev(NULL_REVISION.into())?, | 584 changelog.data_for_rev(NULL_REVISION.into())?, |
572 ChangelogRevisionData::null() | 585 ChangelogRevisionData::null() |