Mercurial > hg
comparison rust/hg-core/src/dirstate_tree/dirstate_map.rs @ 47334:18b3060fe598
dirstate-v2: Add a zero-size error type for dirstate v2 parse errors
This error should only happen if Mercurial is buggy or the file is corrupted.
It indicates for example that:
* A part of the file refers to another part, and the byte offset or item count
would cause reading out of bounds, beyond the end of the file.
* The byte for an entry state has an invalid value
When parsing becomes lazy, many more functions will return a `Result` with
this error. Making it zero-size reduces the work that the `?` operator needs
to do to pass around the error value.
Differential Revision: https://phab.mercurial-scm.org/D10748
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 19 May 2021 13:15:00 +0200 |
parents | 69530e5d4fe5 |
children | ed1583a845d2 |
comparison
equal
deleted
inserted
replaced
47333:69530e5d4fe5 | 47334:18b3060fe598 |
---|---|
226 | 226 |
227 #[timed] | 227 #[timed] |
228 pub fn new_v2( | 228 pub fn new_v2( |
229 on_disk: &'on_disk [u8], | 229 on_disk: &'on_disk [u8], |
230 ) -> Result<(Self, Option<DirstateParents>), DirstateError> { | 230 ) -> Result<(Self, Option<DirstateParents>), DirstateError> { |
231 on_disk::read(on_disk) | 231 Ok(on_disk::read(on_disk)?) |
232 } | 232 } |
233 | 233 |
234 #[timed] | 234 #[timed] |
235 pub fn new_v1( | 235 pub fn new_v1( |
236 on_disk: &'on_disk [u8], | 236 on_disk: &'on_disk [u8], |