D10145: rhg: Return an error code for `rhg config Section.idontexist`
SimonSapin
phabricator at mercurial-scm.org
Tue Mar 9 09:42:56 UTC 2021
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10145
AFFECTED FILES
rust/rhg/src/commands/config.rs
CHANGE DETAILS
diff --git a/rust/rhg/src/commands/config.rs b/rust/rhg/src/commands/config.rs
--- a/rust/rhg/src/commands/config.rs
+++ b/rust/rhg/src/commands/config.rs
@@ -29,8 +29,10 @@
.split_2(b'.')
.ok_or_else(|| HgError::unsupported("hg config <section>"))?;
- let value = invocation.config.get(section, name).unwrap_or(b"");
-
- invocation.ui.write_stdout(&format_bytes!(b"{}\n", value))?;
- Ok(())
+ if let Some(value) = invocation.config.get(section, name) {
+ invocation.ui.write_stdout(&format_bytes!(b"{}\n", value))?;
+ Ok(())
+ } else {
+ Err(CommandError::Unsuccessful)
+ }
}
To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list