Mercurial > hg-stable
changeset 49559:5318ac25dfdc stable
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.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 03 Nov 2022 16:30:35 +0100 |
parents | 05ef5f097df4 |
children | d12446766a35 |
files | mercurial/helptext/config.txt rust/rhg/src/main.rs tests/test-rhg.t |
diffstat | 3 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- 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,
--- 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]