[Request] [+ ] D8864: rhg: Do not return error when when we really mean ok in commands
acezar (Antoine Cezar)
phabricator at mercurial-scm.org
Mon Aug 3 14:27:05 UTC 2020
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/D8864
AFFECTED FILES
rust/rhg/src/commands/root.rs
rust/rhg/src/error.rs
CHANGE DETAILS
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> {
To: acezar, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200803/afa67dcd/attachment.html>
More information about the Mercurial-patches
mailing list