rhg: correctly handle the case where diffs are encoded relative to nullrev
returning a valid entry for nullrev fix chain that delta against nullrev.
--- 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)
--- a/tests/test-revlog.t Sun May 22 23:26:06 2022 +0200
+++ b/tests/test-revlog.t Sun May 22 14:21:59 2022 +0200
@@ -78,12 +78,6 @@
$ 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 ..