changeset 46760:b1e6265e8336

rhg: Return an error code for `rhg config Section.idontexist` This is what Python-based hg does. Differential Revision: https://phab.mercurial-scm.org/D10145
author Simon Sapin <simon.sapin@octobus.net>
date Tue, 09 Mar 2021 09:17:24 +0100
parents eb14264b98e8
children bde90e9b4507
files rust/rhg/src/commands/config.rs
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rust/rhg/src/commands/config.rs	Mon Mar 08 20:04:20 2021 +0100
+++ b/rust/rhg/src/commands/config.rs	Tue Mar 09 09:17:24 2021 +0100
@@ -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)
+    }
 }