comparison rust/rhg/src/commands/config.rs @ 46747: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 92e3cfd63096
children 37bc3edef76f
comparison
equal deleted inserted replaced
46746:eb14264b98e8 46747:b1e6265e8336
27 .expect("missing required CLI argument") 27 .expect("missing required CLI argument")
28 .as_bytes() 28 .as_bytes()
29 .split_2(b'.') 29 .split_2(b'.')
30 .ok_or_else(|| HgError::unsupported("hg config <section>"))?; 30 .ok_or_else(|| HgError::unsupported("hg config <section>"))?;
31 31
32 let value = invocation.config.get(section, name).unwrap_or(b""); 32 if let Some(value) = invocation.config.get(section, name) {
33 33 invocation.ui.write_stdout(&format_bytes!(b"{}\n", value))?;
34 invocation.ui.write_stdout(&format_bytes!(b"{}\n", value))?; 34 Ok(())
35 Ok(()) 35 } else {
36 Err(CommandError::Unsuccessful)
37 }
36 } 38 }