# HG changeset patch # User Raphaël Gomès # Date 1667489435 -3600 # Node ID 5318ac25dfdc5c0b22e02e1fbc2543948491a7ac # Parent 05ef5f097df47d9b05bf3448a58599078feec700 rhg: add a config option to fall back immediately This is useful for debugging the behavior of the "default" `hg` in tests without having to manually substitute the fallback path. diff -r 05ef5f097df4 -r 5318ac25dfdc mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt Thu Nov 03 15:57:37 2022 +0100 +++ b/mercurial/helptext/config.txt Thu Nov 03 16:30:35 2022 +0100 @@ -2165,6 +2165,14 @@ Path to the executable to run in a sub-process when falling back to another implementation of Mercurial. +``fallback-immediately`` + Fall back to ``fallback-executable`` as soon as possible, regardless of + the `rhg.on-unsupported` configuration. Useful for debugging, for example to + bypass `rhg` if the deault `hg` points to `rhg`. + + Note that because this requires loading the configuration, it is possible + that `rhg` error out before being able to fall back. + ``ignored-extensions`` Controls which extensions should be ignored by `rhg`. By default, `rhg` triggers the `rhg.on-unsupported` behavior any unsupported extensions. diff -r 05ef5f097df4 -r 5318ac25dfdc rust/rhg/src/main.rs --- a/rust/rhg/src/main.rs Thu Nov 03 15:57:37 2022 +0100 +++ b/rust/rhg/src/main.rs Thu Nov 03 16:30:35 2022 +0100 @@ -348,6 +348,24 @@ let config = config_cow.as_ref(); let ui = Ui::new(&config) .unwrap_or_else(|error| early_exit(&config, error.into())); + + if let Ok(true) = config.get_bool(b"rhg", b"fallback-immediately") { + exit( + &argv, + &initial_current_dir, + &ui, + OnUnsupported::Fallback { + executable: config + .get(b"rhg", b"fallback-executable") + .map(ToOwned::to_owned), + }, + Err(CommandError::unsupported( + "`rhg.fallback-immediately is true`", + )), + false, + ) + } + let result = main_with_result( argv.iter().map(|s| s.to_owned()).collect(), &process_start_time, diff -r 05ef5f097df4 -r 5318ac25dfdc tests/test-rhg.t --- a/tests/test-rhg.t Thu Nov 03 15:57:37 2022 +0100 +++ b/tests/test-rhg.t Thu Nov 03 16:30:35 2022 +0100 @@ -168,6 +168,10 @@ $ rhg cat original --exclude="*.rs" original content +Check that `fallback-immediately` overrides `$NO_FALLBACK` + $ $NO_FALLBACK rhg cat original --exclude="*.rs" --config rhg.fallback-immediately=1 + original content + $ (unset RHG_FALLBACK_EXECUTABLE; rhg cat original --exclude="*.rs") abort: 'rhg.on-unsupported=fallback' without 'rhg.fallback-executable' set. [255]