# HG changeset patch # User Raphaël Gomès # Date 1698771536 -3600 # Node ID eb676c35a29b2954b2a1bc37e1055d2081561a22 # Parent 456e0fe702e86d6adc3a90bee4785a3718c9ca48 rust-index: support `unionrepo`'s compressed length hack Explanations inline. diff -r 456e0fe702e8 -r eb676c35a29b rust/hg-core/src/revlog/index.rs --- a/rust/hg-core/src/revlog/index.rs Fri Oct 27 23:21:50 2023 +0200 +++ b/rust/hg-core/src/revlog/index.rs Tue Oct 31 17:58:56 2023 +0100 @@ -479,7 +479,18 @@ } else { e.raw_offset() }, - data_compressed_length: e.compressed_len().try_into().unwrap(), + data_compressed_length: e + .compressed_len() + .try_into() + .unwrap_or_else(|_| { + // Python's `unionrepo` sets the compressed length to be + // `-1` (or `u32::MAX` if transmuted to `u32`) because it + // cannot know the correct compressed length of a given + // revision. I'm not sure if this is true, but having this + // edge case won't hurt other use cases, let's handle it. + assert_eq!(e.compressed_len(), u32::MAX); + NULL_REVISION.0 + }), data_uncompressed_length: e.uncompressed_len(), data_delta_base: e.base_revision_or_base_of_delta_chain().0, link_rev: e.link_revision().0,