changeset 45603:be951ca95b08

hg-core: use `.or(Err(Error))` not `.map_err(|_| Error)` (D9100#inline-15067) Differential Revision: https://phab.mercurial-scm.org/D9108
author Antoine cezar<acezar@chwitlabs.fr>
date Mon, 28 Sep 2020 16:52:35 +0200
parents 1cef583541c0
children db11f8f39caf
files rust/hg-core/src/operations/list_tracked_files.rs rust/hg-core/src/revlog/revlog.rs
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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