rust/hg-core/src/operations/list_tracked_files.rs
changeset 46437 b274aa2f20fd
parent 46435 2e2033081274
child 46440 776b97179c06
--- a/rust/hg-core/src/operations/list_tracked_files.rs	Tue Jan 26 20:31:26 2021 +0100
+++ b/rust/hg-core/src/operations/list_tracked_files.rs	Tue Jan 26 20:42:36 2021 +0100
@@ -14,7 +14,6 @@
 use crate::utils::hg_path::HgPath;
 use crate::{DirstateParseError, EntryState};
 use rayon::prelude::*;
-use std::convert::From;
 
 /// Error type for `Dirstate` methods
 #[derive(Debug, derive_more::From)]
@@ -55,59 +54,17 @@
     }
 }
 
-/// Error type `list_rev_tracked_files`
-#[derive(Debug)]
-pub enum ListRevTrackedFilesError {
-    /// Error when reading a `revlog` file.
-    IoError(std::io::Error),
-    /// The revision has not been found.
-    InvalidRevision,
-    /// Found more than one revision whose ID match the requested prefix
-    AmbiguousPrefix,
-    /// A `revlog` file is corrupted.
-    CorruptedRevlog,
-    /// The `revlog` format version is not supported.
-    UnsuportedRevlogVersion(u16),
-    /// The `revlog` data format is not supported.
-    UnknowRevlogDataFormat(u8),
-}
-
-impl From<RevlogError> for ListRevTrackedFilesError {
-    fn from(err: RevlogError) -> Self {
-        match err {
-            RevlogError::IoError(err) => {
-                ListRevTrackedFilesError::IoError(err)
-            }
-            RevlogError::UnsuportedVersion(version) => {
-                ListRevTrackedFilesError::UnsuportedRevlogVersion(version)
-            }
-            RevlogError::InvalidRevision => {
-                ListRevTrackedFilesError::InvalidRevision
-            }
-            RevlogError::AmbiguousPrefix => {
-                ListRevTrackedFilesError::AmbiguousPrefix
-            }
-            RevlogError::Corrupted => {
-                ListRevTrackedFilesError::CorruptedRevlog
-            }
-            RevlogError::UnknowDataFormat(format) => {
-                ListRevTrackedFilesError::UnknowRevlogDataFormat(format)
-            }
-        }
-    }
-}
-
 /// List files under Mercurial control at a given revision.
 pub fn list_rev_tracked_files(
     repo: &Repo,
     revset: &str,
-) -> Result<FilesForRev, ListRevTrackedFilesError> {
+) -> Result<FilesForRev, RevlogError> {
     let rev = crate::revset::resolve_single(revset, repo)?;
     let changelog = Changelog::open(repo)?;
     let manifest = Manifest::open(repo)?;
     let changelog_entry = changelog.get_rev(rev)?;
     let manifest_node = Node::from_hex(&changelog_entry.manifest_node()?)
-        .or(Err(ListRevTrackedFilesError::CorruptedRevlog))?;
+        .map_err(|_| RevlogError::Corrupted)?;
     let manifest_entry = manifest.get_node(manifest_node.into())?;
     Ok(FilesForRev(manifest_entry))
 }