diff --git a/rust/hg-core/src/revlog/revlog.rs b/rust/hg-core/src/revlog/revlog.rs --- a/rust/hg-core/src/revlog/revlog.rs +++ b/rust/hg-core/src/revlog/revlog.rs @@ -32,6 +32,8 @@ const REVIDX_KNOWN_FLAGS: u16 = REVISION | REVISION_FLAG_EXTSTORED | REVISION_FLAG_HASCOPIESINFO; +const NULL_REVLOG_ENTRY_FLAGS: u16 = 0; + #[derive(derive_more::From)] pub enum RevlogError { InvalidRevision, @@ -262,11 +264,29 @@ impl Revlog { } } + pub fn make_null_entry(&self) -> RevlogEntry { + RevlogEntry { + revlog: self, + rev: NULL_REVISION, + bytes: b"", + compressed_len: 0, + uncompressed_len: 0, + base_rev_or_base_of_delta_chain: None, + p1: NULL_REVISION, + p2: NULL_REVISION, + flags: NULL_REVLOG_ENTRY_FLAGS, + hash: NULL_NODE, + } + } + /// Get an entry of the revlog. pub fn get_entry( &self, rev: Revision, ) -> Result { + if rev == NULL_REVISION { + return Ok(self.make_null_entry()); + } let index_entry = self .index .get_entry(rev) diff --git a/tests/test-revlog.t b/tests/test-revlog.t --- a/tests/test-revlog.t +++ b/tests/test-revlog.t @@ -78,12 +78,6 @@ This is what we did to produce the repo $ hg debugdeltachain a rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio readsize largestblk rddensity srchunks 0 1 2 -1 p1 15 3 15 5.00000 15 0 0.00000 15 15 1.00000 1 -#if rhg - $ hg cat --config rhg.cat=true -r 0 a - abort: corrupted revlog - [255] -#else $ hg cat --config rhg.cat=true -r 0 a hi -#endif $ cd ..