Mercurial > hg
comparison rust/hg-core/src/revlog/changelog.rs @ 50746:124c44b5cfad stable
rust-revlog: fix RevlogEntry.data() for NULL_REVISION
Before this change, the pseudo-entry returned by `Revlog.get_entry` for
`NULL_REVISION` would trigger errors in application code using it.
For example, this fixes a crash spotted with changelog data
while implementing RHGitaly: `Changelog.data_for_rev(-1)` was already
returning the pseudo content as expected, e.g., for `hg log`, but
`Changelog.entry_for_rev(-1).data()` would still crash with
"corrupted revlog, hash check failed for revision -1". There is
an added test for this scenario.
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Thu, 06 Jul 2023 11:53:40 +0200 |
parents | 071a6c1d291e |
children | 9865af7191d2 |
comparison
equal
deleted
inserted
replaced
50745:3338c6ffdaa3 | 50746:124c44b5cfad |
---|---|
334 let changelog = Changelog { revlog }; | 334 let changelog = Changelog { revlog }; |
335 assert_eq!( | 335 assert_eq!( |
336 changelog.data_for_rev(NULL_REVISION)?, | 336 changelog.data_for_rev(NULL_REVISION)?, |
337 ChangelogRevisionData::null() | 337 ChangelogRevisionData::null() |
338 ); | 338 ); |
339 // same with the intermediate entry object | |
340 assert_eq!( | |
341 changelog.entry_for_rev(NULL_REVISION)?.data()?, | |
342 ChangelogRevisionData::null() | |
343 ); | |
339 Ok(()) | 344 Ok(()) |
340 } | 345 } |
341 } | 346 } |