rhg: Return an error code for `rhg config Section.idontexist`
authorSimon Sapin <simon.sapin@octobus.net>
Tue, 09 Mar 2021 09:17:24 +0100
changeset 46747 b1e6265e8336
parent 46746 eb14264b98e8
child 46748 bde90e9b4507
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
rust/rhg/src/commands/config.rs
--- 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)
+    }
 }