##// END OF EJS Templates
rhg: make `rhg files` work if `ui.relative-files=true` is specified
Arseniy Alekseyev -
r51432:74e4dbb0 default
parent child Browse files
Show More
@@ -1,5 +1,5 b''
1 use crate::error::CommandError;
1 use crate::error::CommandError;
2 use crate::ui::{print_narrow_sparse_warnings, Ui};
2 use crate::ui::{print_narrow_sparse_warnings, Ui, RelativePaths, relative_paths};
3 use crate::utils::path_utils::RelativizePaths;
3 use crate::utils::path_utils::RelativizePaths;
4 use clap::Arg;
4 use clap::Arg;
5 use hg::narrow;
5 use hg::narrow;
@@ -28,11 +28,13 b' pub fn args() -> clap::Command {'
28 }
28 }
29
29
30 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
30 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
31 let relative = invocation.config.get(b"ui", b"relative-paths");
31 match relative_paths(invocation.config)? {
32 if relative.is_some() {
32 RelativePaths::Legacy | RelativePaths::Bool(true) => (),
33 RelativePaths::Bool(false) => {
33 return Err(CommandError::unsupported(
34 return Err(CommandError::unsupported(
34 "non-default ui.relative-paths",
35 "non-default ui.relative-paths",
35 ));
36 ));
37 }
36 }
38 }
37
39
38 let rev = invocation.subcommand_args.get_one::<String>("rev");
40 let rev = invocation.subcommand_args.get_one::<String>("rev");
@@ -221,6 +221,18 b' pub fn formatted(config: &Config) -> Res'
221 }
221 }
222 }
222 }
223
223
224 pub enum RelativePaths {
225 Legacy,
226 Bool(bool),
227 }
228
229 pub fn relative_paths(config: &Config) -> Result<RelativePaths, HgError> {
230 Ok(match config.get(b"ui", b"relative-paths") {
231 None | Some(b"legacy") => RelativePaths::Legacy,
232 _ => RelativePaths::Bool(config.get_bool(b"ui", b"relative-paths")?),
233 })
234 }
235
224 fn isatty(config: &Config) -> Result<bool, HgError> {
236 fn isatty(config: &Config) -> Result<bool, HgError> {
225 Ok(if config.get_bool(b"ui", b"nontty")? {
237 Ok(if config.get_bool(b"ui", b"nontty")? {
226 false
238 false
@@ -72,16 +72,18 b' Listing tracked files from subdirectory'
72 ../../../file3
72 ../../../file3
73
73
74 $ $NO_FALLBACK rhg files --config ui.relative-paths=legacy
74 $ $NO_FALLBACK rhg files --config ui.relative-paths=legacy
75 unsupported feature: non-default ui.relative-paths
75 ../../../file1
76 [252]
76 ../../../file2
77 ../../../file3
77
78
78 $ $NO_FALLBACK rhg files --config ui.relative-paths=false
79 $ $NO_FALLBACK rhg files --config ui.relative-paths=false
79 unsupported feature: non-default ui.relative-paths
80 unsupported feature: non-default ui.relative-paths
80 [252]
81 [252]
81
82
82 $ $NO_FALLBACK rhg files --config ui.relative-paths=true
83 $ $NO_FALLBACK rhg files --config ui.relative-paths=true
83 unsupported feature: non-default ui.relative-paths
84 ../../../file1
84 [252]
85 ../../../file2
86 ../../../file3
85
87
86 Listing tracked files through broken pipe
88 Listing tracked files through broken pipe
87 $ $NO_FALLBACK rhg files | head -n 1
89 $ $NO_FALLBACK rhg files | head -n 1
General Comments 0
You need to be logged in to leave comments. Login now