Patchwork D8776: rhg: Do not return error when when we really mean ok in commands

login
register
mail settings
Submitter phabricator
Date July 21, 2020, 2:07 p.m.
Message ID <differential-rev-PHID-DREV-tzwfh62dr64hujf2an5p-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46820/
State Superseded
Headers show

Comments

phabricator - July 21, 2020, 2:07 p.m.
acezar created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8776

AFFECTED FILES
  rust/rhg/src/commands/root.rs
  rust/rhg/src/error.rs

CHANGE DETAILS




To: acezar, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/rhg/src/error.rs b/rust/rhg/src/error.rs
--- a/rust/rhg/src/error.rs
+++ b/rust/rhg/src/error.rs
@@ -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,
diff --git a/rust/rhg/src/commands/root.rs b/rust/rhg/src/commands/root.rs
--- a/rust/rhg/src/commands/root.rs
+++ b/rust/rhg/src/commands/root.rs
@@ -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> {