Show More
@@ -1,5 +1,5 b'' | |||
|
1 | 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 | 3 | use crate::utils::path_utils::RelativizePaths; |
|
4 | 4 | use clap::Arg; |
|
5 | 5 | use hg::narrow; |
@@ -28,11 +28,13 b' pub fn args() -> clap::Command {' | |||
|
28 | 28 | } |
|
29 | 29 | |
|
30 | 30 | pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> { |
|
31 | let relative = invocation.config.get(b"ui", b"relative-paths"); | |
|
32 | if relative.is_some() { | |
|
31 | match relative_paths(invocation.config)? { | |
|
32 | RelativePaths::Legacy | RelativePaths::Bool(true) => (), | |
|
33 | RelativePaths::Bool(false) => { | |
|
33 | 34 | return Err(CommandError::unsupported( |
|
34 | 35 | "non-default ui.relative-paths", |
|
35 | 36 | )); |
|
37 | } | |
|
36 | 38 | } |
|
37 | 39 | |
|
38 | 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 | 236 | fn isatty(config: &Config) -> Result<bool, HgError> { |
|
225 | 237 | Ok(if config.get_bool(b"ui", b"nontty")? { |
|
226 | 238 | false |
@@ -72,16 +72,18 b' Listing tracked files from subdirectory' | |||
|
72 | 72 | ../../../file3 |
|
73 | 73 | |
|
74 | 74 | $ $NO_FALLBACK rhg files --config ui.relative-paths=legacy |
|
75 | unsupported feature: non-default ui.relative-paths | |
|
76 | [252] | |
|
75 | ../../../file1 | |
|
76 | ../../../file2 | |
|
77 | ../../../file3 | |
|
77 | 78 | |
|
78 | 79 | $ $NO_FALLBACK rhg files --config ui.relative-paths=false |
|
79 | 80 | unsupported feature: non-default ui.relative-paths |
|
80 | 81 | [252] |
|
81 | 82 | |
|
82 | 83 | $ $NO_FALLBACK rhg files --config ui.relative-paths=true |
|
83 | unsupported feature: non-default ui.relative-paths | |
|
84 | [252] | |
|
84 | ../../../file1 | |
|
85 | ../../../file2 | |
|
86 | ../../../file3 | |
|
85 | 87 | |
|
86 | 88 | Listing tracked files through broken pipe |
|
87 | 89 | $ $NO_FALLBACK rhg files | head -n 1 |
General Comments 0
You need to be logged in to leave comments.
Login now