Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/dirstate/parsers.rs @ 47343:ed1583a845d2
dirstate-v2: Make more APIs fallible, returning Result
When parsing becomes lazy, parse error will potentially happen in more places.
This propagates such errors to callers.
Differential Revision: https://phab.mercurial-scm.org/D10749
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 19 May 2021 13:15:00 +0200 |
parents | 73f23e7610f8 |
children | 3b9914b28133 |
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate/parsers.rs Wed May 19 13:15:00 2021 +0200 +++ b/rust/hg-core/src/dirstate/parsers.rs Wed May 19 13:15:00 2021 +0200 @@ -43,13 +43,18 @@ copies.push((path, source)); } entries.push((path, *entry)); + Ok(()) })?; Ok((parents, entries, copies)) } pub fn parse_dirstate_entries<'a>( mut contents: &'a [u8], - mut each_entry: impl FnMut(&'a HgPath, &DirstateEntry, Option<&'a HgPath>), + mut each_entry: impl FnMut( + &'a HgPath, + &DirstateEntry, + Option<&'a HgPath>, + ) -> Result<(), HgError>, ) -> Result<&'a DirstateParents, HgError> { let (parents, rest) = DirstateParents::from_bytes(contents) .map_err(|_| HgError::corrupted("Too little data for dirstate."))?; @@ -75,7 +80,7 @@ iter.next().expect("splitn always yields at least one item"), ); let copy_source = iter.next().map(HgPath::new); - each_entry(path, &entry, copy_source); + each_entry(path, &entry, copy_source)?; contents = rest; }