Fallback if it is requested explicitly.
The default is documented as use color "whenever it seems possible".
rhg proceeds without color in that case.
Alphare |
hg-reviewers |
Fallback if it is requested explicitly.
The default is documented as use color "whenever it seems possible".
rhg proceeds without color in that case.
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/rhg/src/main.rs (13 lines) | |||
M | tests/test-status-color.t (4 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
1c6bf9fd8faf | c8f7b3e1b860 | Simon Sapin | Nov 9 2021, 1:28 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin | ||
Closed | SimonSapin |
} | } | ||||
fn main_with_result( | fn main_with_result( | ||||
process_start_time: &blackbox::ProcessStartTime, | process_start_time: &blackbox::ProcessStartTime, | ||||
ui: &ui::Ui, | ui: &ui::Ui, | ||||
repo: Result<&Repo, &NoRepoInCwdError>, | repo: Result<&Repo, &NoRepoInCwdError>, | ||||
config: &Config, | config: &Config, | ||||
) -> Result<(), CommandError> { | ) -> Result<(), CommandError> { | ||||
check_unsupported(config)?; | check_unsupported(config, ui)?; | ||||
let app = App::new("rhg") | let app = App::new("rhg") | ||||
.global_setting(AppSettings::AllowInvalidUtf8) | .global_setting(AppSettings::AllowInvalidUtf8) | ||||
.global_setting(AppSettings::DisableVersion) | .global_setting(AppSettings::DisableVersion) | ||||
.setting(AppSettings::SubcommandRequired) | .setting(AppSettings::SubcommandRequired) | ||||
.setting(AppSettings::VersionlessSubcommands) | .setting(AppSettings::VersionlessSubcommands) | ||||
.arg( | .arg( | ||||
Arg::with_name("repository") | Arg::with_name("repository") | ||||
message: format_bytes!( | message: format_bytes!( | ||||
b"extensions: {} (consider adding them to 'rhg.ignored-extensions' config)", | b"extensions: {} (consider adding them to 'rhg.ignored-extensions' config)", | ||||
join(unsupported, b", ") | join(unsupported, b", ") | ||||
), | ), | ||||
}) | }) | ||||
} | } | ||||
} | } | ||||
fn check_unsupported(config: &Config) -> Result<(), CommandError> { | fn check_unsupported( | ||||
config: &Config, | |||||
ui: &ui::Ui, | |||||
) -> Result<(), CommandError> { | |||||
check_extensions(config)?; | check_extensions(config)?; | ||||
if std::env::var_os("HG_PENDING").is_some() { | if std::env::var_os("HG_PENDING").is_some() { | ||||
// TODO: only if the value is `== repo.working_directory`? | // TODO: only if the value is `== repo.working_directory`? | ||||
// What about relative v.s. absolute paths? | // What about relative v.s. absolute paths? | ||||
Err(CommandError::unsupported("$HG_PENDING"))? | Err(CommandError::unsupported("$HG_PENDING"))? | ||||
} | } | ||||
if config.has_non_empty_section(b"encode") { | if config.has_non_empty_section(b"encode") { | ||||
Err(CommandError::unsupported("[encode] config"))? | Err(CommandError::unsupported("[encode] config"))? | ||||
} | } | ||||
if config.has_non_empty_section(b"decode") { | if config.has_non_empty_section(b"decode") { | ||||
Err(CommandError::unsupported("[decode] config"))? | Err(CommandError::unsupported("[decode] config"))? | ||||
} | } | ||||
if let Some(color) = config.get(b"ui", b"color") { | |||||
if (color == b"always" || color == b"debug") && !ui.plain() { | |||||
Err(CommandError::unsupported("colored output"))? | |||||
} | |||||
} | |||||
Ok(()) | Ok(()) | ||||
} | } |
TODO: fix rhg bugs that make this test fail when status is enabled | |||||
$ unset RHG_STATUS | |||||
$ cat <<EOF >> $HGRCPATH | $ cat <<EOF >> $HGRCPATH | ||||
> [ui] | > [ui] | ||||
> color = always | > color = always | ||||
> [color] | > [color] | ||||
> mode = ansi | > mode = ansi | ||||
> EOF | > EOF | ||||
Terminfo codes compatibility fix | Terminfo codes compatibility fix | ||||
$ echo "color.none=0" >> $HGRCPATH | $ echo "color.none=0" >> $HGRCPATH |