Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/revlog/revlog.rs @ 49210:cc92ad0e8185 stable
rhg: correctly handle the case where diffs are encoded relative to nullrev
returning a valid entry for nullrev fix chain that delta against nullrev.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Sun, 22 May 2022 14:21:59 +0200 |
parents | e91aa800ae5b |
children | 13dfad0f9f7a |
line wrap: on
line diff
--- a/rust/hg-core/src/revlog/revlog.rs Sun May 22 23:26:06 2022 +0200 +++ b/rust/hg-core/src/revlog/revlog.rs Sun May 22 14:21:59 2022 +0200 @@ -32,6 +32,8 @@ | 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 @@ } } + 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<RevlogEntry, RevlogError> { + if rev == NULL_REVISION { + return Ok(self.make_null_entry()); + } let index_entry = self .index .get_entry(rev)