# HG changeset patch # User Georges Racinet # Date 1680116619 -7200 # Node ID b5dd6d6d6fa61b5fa870aadebe016685b30e75f1 # Parent b47a9316050aa583a006cef9d60195e2ed6c41a1 rust-changelog: added a test for `NULL_REVISION` special case The result is due to `Revlog.get_rev_data()` returning an empty byte string for `NULL_REVISION`, followed by special case for emtpty byte strings in `ChangelogRevisionData::new()`. diff -r b47a9316050a -r b5dd6d6d6fa6 rust/hg-core/src/revlog/changelog.rs --- a/rust/hg-core/src/revlog/changelog.rs Wed Mar 29 20:24:58 2023 +0200 +++ b/rust/hg-core/src/revlog/changelog.rs Wed Mar 29 21:03:39 2023 +0200 @@ -215,6 +215,8 @@ #[cfg(test)] mod tests { use super::*; + use crate::vfs::Vfs; + use crate::NULL_REVISION; use pretty_assertions::assert_eq; #[test] @@ -268,4 +270,20 @@ ); assert_eq!(data.description(), b"some\ncommit\nmessage"); } + + #[test] + fn test_data_from_rev_null() -> Result<(), RevlogError> { + // an empty revlog will be enough for this case + let temp = tempfile::tempdir().unwrap(); + let vfs = Vfs { base: temp.path() }; + std::fs::write(temp.path().join("foo.i"), b"").unwrap(); + let revlog = Revlog::open(&vfs, "foo.i", None, false).unwrap(); + + let changelog = Changelog { revlog }; + assert_eq!( + changelog.data_for_rev(NULL_REVISION)?, + ChangelogRevisionData::null() + ); + Ok(()) + } }