comparison rust/rhg/src/main.rs @ 50764:8ff187fbbfea

rust-config: add config getters that don't fall back to defaults This is useful in cases where we access config items that are more... lenient with their types than a fresh new system would allow. For now there is only a single use of this, but we might get more later.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 13 Feb 2023 18:11:48 +0100
parents 14b57943ae6d
children 53d77f96e049
comparison
equal deleted inserted replaced
50763:f8412da86d05 50764:8ff187fbbfea
84 84
85 for prefix in ["pre", "post", "fail"].iter() { 85 for prefix in ["pre", "post", "fail"].iter() {
86 // Mercurial allows users to define generic hooks for commands, 86 // Mercurial allows users to define generic hooks for commands,
87 // fallback if any are detected 87 // fallback if any are detected
88 let item = format!("{}-{}", prefix, subcommand_name); 88 let item = format!("{}-{}", prefix, subcommand_name);
89 let hook_for_command = config.get_str(b"hooks", item.as_bytes())?; 89 let hook_for_command =
90 config.get_str_no_default(b"hooks", item.as_bytes())?;
90 if hook_for_command.is_some() { 91 if hook_for_command.is_some() {
91 let msg = format!("{}-{} hook defined", prefix, subcommand_name); 92 let msg = format!("{}-{} hook defined", prefix, subcommand_name);
92 return Err(CommandError::unsupported(msg)); 93 return Err(CommandError::unsupported(msg));
93 } 94 }
94 } 95 }