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) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
076fdaf696e4 | e883c1247244 | 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") | ||||
} else { | } else { | ||||
Err(CommandError::UnsupportedFeature { message: format_bytes!( | Err(CommandError::UnsupportedFeature { 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(()) | ||||
} | } |