hg-core: use `.or(Err(Error))` not `.map_err(|_| Error)` (D9100#inline-15067)
Differential Revision: https://phab.mercurial-scm.org/D9108
--- a/rust/hg-core/src/operations/list_tracked_files.rs Mon Sep 28 15:21:56 2020 +0200
+++ b/rust/hg-core/src/operations/list_tracked_files.rs Mon Sep 28 16:52:35 2020 +0200
@@ -166,14 +166,13 @@
let changelog_entry = match self.rev.parse::<Revision>() {
Ok(rev) => self.changelog.get_rev(rev)?,
_ => {
- let changelog_node = hex::decode(&self.rev).map_err(|_| {
- ListRevTrackedFilesErrorKind::InvalidRevision
- })?;
+ let changelog_node = hex::decode(&self.rev)
+ .or(Err(ListRevTrackedFilesErrorKind::InvalidRevision))?;
self.changelog.get_node(&changelog_node)?
}
};
let manifest_node = hex::decode(&changelog_entry.manifest_node()?)
- .map_err(|_| ListRevTrackedFilesErrorKind::CorruptedRevlog)?;
+ .or(Err(ListRevTrackedFilesErrorKind::CorruptedRevlog))?;
self.manifest_entry = Some(self.manifest.get_node(&manifest_node)?);
--- a/rust/hg-core/src/revlog/revlog.rs Mon Sep 28 15:21:56 2020 +0200
+++ b/rust/hg-core/src/revlog/revlog.rs Mon Sep 28 16:52:35 2020 +0200
@@ -111,9 +111,8 @@
let mut delta_chain = vec![];
while let Some(base_rev) = entry.base_rev {
delta_chain.push(entry);
- entry = self
- .get_entry(base_rev)
- .map_err(|_| RevlogError::Corrupted)?;
+ entry =
+ self.get_entry(base_rev).or(Err(RevlogError::Corrupted))?;
}
// TODO do not look twice in the index