# HG changeset patch # User Spencer Baugh # Date 2023-08-31 23:47:33 # Node ID 12476986d89c0546c3d0c33328b1b7d9258418db # Parent 2eca8b5c8cbdd945bf862b98f88f7118faf46132 rhg: allow setting defaults.cmd to an empty string This is used by at least one hg UI to prevent defaults from affecting the command: https://github.com/emacs-mirror/emacs/blob/b71beb7ae7c60a5c5af608420d28fdda5265a264/lisp/vc/vc-hg.el#L245 Let's let it work. diff --git a/rust/rhg/src/main.rs b/rust/rhg/src/main.rs --- a/rust/rhg/src/main.rs +++ b/rust/rhg/src/main.rs @@ -76,10 +76,15 @@ fn main_with_result( // Mercurial allows users to define "defaults" for commands, fallback // if a default is detected for the current command - let defaults = config.get_str(b"defaults", subcommand_name.as_bytes()); - if defaults?.is_some() { - let msg = "`defaults` config set"; - return Err(CommandError::unsupported(msg)); + let defaults = config.get_str(b"defaults", subcommand_name.as_bytes())?; + match defaults { + // Programmatic usage might set defaults to an empty string to unset + // it; allow that + None | Some("") => {} + Some(_) => { + let msg = "`defaults` config set"; + return Err(CommandError::unsupported(msg)); + } } for prefix in ["pre", "post", "fail"].iter() {