##// END OF EJS Templates
rhg: Add support for HGPLAINEXPECT...
Simon Sapin -
r49580:99b1dfc0 default
parent child Browse files
Show More
@@ -183,7 +183,7 b' pub fn run(invocation: &crate::CliInvoca'
183 let config = invocation.config;
183 let config = invocation.config;
184 let args = invocation.subcommand_args;
184 let args = invocation.subcommand_args;
185
185
186 let verbose = !ui.plain()
186 let verbose = !ui.plain(None)
187 && !args.is_present("print0")
187 && !args.is_present("print0")
188 && (config.get_bool(b"ui", b"verbose")?
188 && (config.get_bool(b"ui", b"verbose")?
189 || config.get_bool(b"commands", b"status.verbose")?);
189 || config.get_bool(b"commands", b"status.verbose")?);
@@ -312,7 +312,7 b' pub fn run(invocation: &crate::CliInvoca'
312 }
312 }
313 }
313 }
314 }
314 }
315 let relative_paths = (!ui.plain())
315 let relative_paths = (!ui.plain(None))
316 && config
316 && config
317 .get_option(b"commands", b"status.relative")?
317 .get_option(b"commands", b"status.relative")?
318 .unwrap_or(config.get_bool(b"ui", b"relative-paths")?);
318 .unwrap_or(config.get_bool(b"ui", b"relative-paths")?);
@@ -669,7 +669,9 b' fn check_unsupported('
669 }
669 }
670
670
671 if let Some(color) = config.get(b"ui", b"color") {
671 if let Some(color) = config.get(b"ui", b"color") {
672 if (color == b"always" || color == b"debug") && !ui.plain() {
672 if (color == b"always" || color == b"debug")
673 && !ui.plain(Some("color"))
674 {
673 Err(CommandError::unsupported("colored output"))?
675 Err(CommandError::unsupported("colored output"))?
674 }
676 }
675 }
677 }
@@ -1,4 +1,5 b''
1 use format_bytes::format_bytes;
1 use format_bytes::format_bytes;
2 use hg::utils::files::get_bytes_from_os_string;
2 use std::borrow::Cow;
3 use std::borrow::Cow;
3 use std::env;
4 use std::env;
4 use std::io;
5 use std::io;
@@ -65,8 +66,19 b' impl Ui {'
65 /// - False if HGPLAIN is not set, or feature is in HGPLAINEXCEPT
66 /// - False if HGPLAIN is not set, or feature is in HGPLAINEXCEPT
66 /// - False if feature is disabled by default and not included in HGPLAIN
67 /// - False if feature is disabled by default and not included in HGPLAIN
67 /// - True otherwise
68 /// - True otherwise
68 pub fn plain(&self) -> bool {
69 pub fn plain(&self, feature: Option<&str>) -> bool {
69 // TODO: add support for HGPLAINEXCEPT
70 plain(feature)
71 }
72 }
73
74 fn plain(opt_feature: Option<&str>) -> bool {
75 if let Some(except) = env::var_os("HGPLAINEXCEPT") {
76 opt_feature.map_or(true, |feature| {
77 get_bytes_from_os_string(except)
78 .split(|&byte| byte == b',')
79 .all(|exception| exception != feature.as_bytes())
80 })
81 } else {
70 env::var_os("HGPLAIN").is_some()
82 env::var_os("HGPLAIN").is_some()
71 }
83 }
72 }
84 }
General Comments 0
You need to be logged in to leave comments. Login now