comparison rust/rhg/src/main.rs @ 48389:d71b9902e2de

rhg: Colored output is not supported Fallback if it is requested explicitly. The default is documented as use color "whenever it seems possible". rhg proceeds without color in that case. Differential Revision: https://phab.mercurial-scm.org/D11762
author Simon Sapin <simon.sapin@octobus.net>
date Tue, 09 Nov 2021 19:28:13 +0100
parents a2e278b5e265
children 8960295b9246
comparison
equal deleted inserted replaced
48388:a2e278b5e265 48389:d71b9902e2de
26 process_start_time: &blackbox::ProcessStartTime, 26 process_start_time: &blackbox::ProcessStartTime,
27 ui: &ui::Ui, 27 ui: &ui::Ui,
28 repo: Result<&Repo, &NoRepoInCwdError>, 28 repo: Result<&Repo, &NoRepoInCwdError>,
29 config: &Config, 29 config: &Config,
30 ) -> Result<(), CommandError> { 30 ) -> Result<(), CommandError> {
31 check_unsupported(config)?; 31 check_unsupported(config, ui)?;
32 32
33 let app = App::new("rhg") 33 let app = App::new("rhg")
34 .global_setting(AppSettings::AllowInvalidUtf8) 34 .global_setting(AppSettings::AllowInvalidUtf8)
35 .global_setting(AppSettings::DisableVersion) 35 .global_setting(AppSettings::DisableVersion)
36 .setting(AppSettings::SubcommandRequired) 36 .setting(AppSettings::SubcommandRequired)
615 ), 615 ),
616 }) 616 })
617 } 617 }
618 } 618 }
619 619
620 fn check_unsupported(config: &Config) -> Result<(), CommandError> { 620 fn check_unsupported(
621 config: &Config,
622 ui: &ui::Ui,
623 ) -> Result<(), CommandError> {
621 check_extensions(config)?; 624 check_extensions(config)?;
622 625
623 if std::env::var_os("HG_PENDING").is_some() { 626 if std::env::var_os("HG_PENDING").is_some() {
624 // TODO: only if the value is `== repo.working_directory`? 627 // TODO: only if the value is `== repo.working_directory`?
625 // What about relative v.s. absolute paths? 628 // What about relative v.s. absolute paths?
632 635
633 if config.has_non_empty_section(b"decode") { 636 if config.has_non_empty_section(b"decode") {
634 Err(CommandError::unsupported("[decode] config"))? 637 Err(CommandError::unsupported("[decode] config"))?
635 } 638 }
636 639
640 if let Some(color) = config.get(b"ui", b"color") {
641 if (color == b"always" || color == b"debug") && !ui.plain() {
642 Err(CommandError::unsupported("colored output"))?
643 }
644 }
645
637 Ok(()) 646 Ok(())
638 } 647 }