rhg: Do not return error when when we really mean ok in commands
authorAntoine Cezar <antoine.cezar@octobus.net>
Tue, 21 Jul 2020 10:39:30 +0200
changeset 45380 227281e76c22
parent 45379 0f5286ccf82c
child 45381 47997afadf08
rhg: Do not return error when when we really mean ok in commands Before when a command was successfull `Err(CommandErrorKind::Ok.into())` was returned which is an oxymoron. Using `Ok(())` when everything is ok seems more appropriate. Differential Revision: https://phab.mercurial-scm.org/D8864
rust/rhg/src/commands/root.rs
rust/rhg/src/error.rs
--- a/rust/rhg/src/commands/root.rs	Sat Aug 08 12:52:39 2020 -0700
+++ b/rust/rhg/src/commands/root.rs	Tue Jul 21 10:39:30 2020 +0200
@@ -29,7 +29,7 @@
         // TODO use formating macro
         self.ui.write_stdout(&[bytes.as_slice(), b"\n"].concat())?;
 
-        Err(CommandErrorKind::Ok.into())
+        Ok(())
     }
 
     fn display_error(&self, error: FindRootError) -> Result<(), CommandError> {
--- a/rust/rhg/src/error.rs	Sat Aug 08 12:52:39 2020 -0700
+++ b/rust/rhg/src/error.rs	Tue Jul 21 10:39:30 2020 +0200
@@ -5,8 +5,6 @@
 /// The kind of command error
 #[derive(Debug, PartialEq)]
 pub enum CommandErrorKind {
-    /// The command finished without error
-    Ok,
     /// The root of the repository cannot be found
     RootNotFound,
     /// The current directory cannot be found
@@ -20,7 +18,6 @@
 impl CommandErrorKind {
     pub fn get_exit_code(&self) -> exitcode::ExitCode {
         match self {
-            CommandErrorKind::Ok => exitcode::OK,
             CommandErrorKind::RootNotFound => exitcode::ABORT,
             CommandErrorKind::CurrentDirNotFound => exitcode::ABORT,
             CommandErrorKind::StdoutError => exitcode::ABORT,