hg-core: use `.or(Err(Error))` not `.map_err(|_| Error)` (D9100#inline-15067)
authorAntoine cezar<acezar@chwitlabs.fr>
Mon, 28 Sep 2020 16:52:35 +0200
changeset 45603 be951ca95b08
parent 45602 1cef583541c0
child 45604 db11f8f39caf
hg-core: use `.or(Err(Error))` not `.map_err(|_| Error)` (D9100#inline-15067) Differential Revision: https://phab.mercurial-scm.org/D9108
rust/hg-core/src/operations/list_tracked_files.rs
rust/hg-core/src/revlog/revlog.rs
--- 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