# HG changeset patch # User Arseniy Alekseyev # Date 1685375598 -3600 # Node ID 74e4dbb0fcd52894bd68a49de5deac6910b6b228 # Parent a7513d0d451b5dd7bfdb384eb30f021f429a312f rhg: make `rhg files` work if `ui.relative-files=true` is specified diff -r a7513d0d451b -r 74e4dbb0fcd5 rust/rhg/src/commands/files.rs --- a/rust/rhg/src/commands/files.rs Mon May 29 16:47:39 2023 +0100 +++ b/rust/rhg/src/commands/files.rs Mon May 29 16:53:18 2023 +0100 @@ -1,5 +1,5 @@ use crate::error::CommandError; -use crate::ui::{print_narrow_sparse_warnings, Ui}; +use crate::ui::{print_narrow_sparse_warnings, Ui, RelativePaths, relative_paths}; use crate::utils::path_utils::RelativizePaths; use clap::Arg; use hg::narrow; @@ -28,11 +28,13 @@ } pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { - let relative = invocation.config.get(b"ui", b"relative-paths"); - if relative.is_some() { + match relative_paths(invocation.config)? { + RelativePaths::Legacy | RelativePaths::Bool(true) => (), + RelativePaths::Bool(false) => { return Err(CommandError::unsupported( "non-default ui.relative-paths", )); + } } let rev = invocation.subcommand_args.get_one::("rev"); diff -r a7513d0d451b -r 74e4dbb0fcd5 rust/rhg/src/ui.rs --- a/rust/rhg/src/ui.rs Mon May 29 16:47:39 2023 +0100 +++ b/rust/rhg/src/ui.rs Mon May 29 16:53:18 2023 +0100 @@ -221,6 +221,18 @@ } } +pub enum RelativePaths { + Legacy, + Bool(bool), +} + +pub fn relative_paths(config: &Config) -> Result { + Ok(match config.get(b"ui", b"relative-paths") { + None | Some(b"legacy") => RelativePaths::Legacy, + _ => RelativePaths::Bool(config.get_bool(b"ui", b"relative-paths")?), + }) +} + fn isatty(config: &Config) -> Result { Ok(if config.get_bool(b"ui", b"nontty")? { false diff -r a7513d0d451b -r 74e4dbb0fcd5 tests/test-rhg.t --- a/tests/test-rhg.t Mon May 29 16:47:39 2023 +0100 +++ b/tests/test-rhg.t Mon May 29 16:53:18 2023 +0100 @@ -72,16 +72,18 @@ ../../../file3 $ $NO_FALLBACK rhg files --config ui.relative-paths=legacy - unsupported feature: non-default ui.relative-paths - [252] + ../../../file1 + ../../../file2 + ../../../file3 $ $NO_FALLBACK rhg files --config ui.relative-paths=false unsupported feature: non-default ui.relative-paths [252] $ $NO_FALLBACK rhg files --config ui.relative-paths=true - unsupported feature: non-default ui.relative-paths - [252] + ../../../file1 + ../../../file2 + ../../../file3 Listing tracked files through broken pipe $ $NO_FALLBACK rhg files | head -n 1