##// END OF EJS Templates
extensions: make `hg nonexistent` not crash with PyOxidizer...
extensions: make `hg nonexistent` not crash with PyOxidizer When running `hg nonexistent`, we try to look for extensions that provide that command. We do that by looking for files in the `hgext.__file__` directory. However, PyOxidizer doesn't provide a `__file__`, so we crash when running with PyOxidizer. We should be able to look for the command in built-in extensions, but we seem to already have code for skipping the scan when running in a frozen binary, so I just modified that code instead. By the way, it also seems like we should be able to search for extensions in the `hgext3rd` module, but we don't do that yet either (before or after this patch). Differential Revision: https://phab.mercurial-scm.org/D8750

File last commit:

r45571:3707f6e7 default
r45665:5d09a120 default
Show More
main.rs
42 lines | 1.1 KiB | application/rls-services+xml | RustLexer
use clap::App;
use clap::AppSettings;
use clap::SubCommand;
mod commands;
mod error;
mod exitcode;
mod ui;
use commands::Command;
fn main() {
let mut app = App::new("rhg")
.setting(AppSettings::AllowInvalidUtf8)
.setting(AppSettings::SubcommandRequired)
.setting(AppSettings::VersionlessSubcommands)
.version("0.0.1")
.subcommand(
SubCommand::with_name("root").about(commands::root::HELP_TEXT),
);
let matches = app.clone().get_matches_safe().unwrap_or_else(|_| {
std::process::exit(exitcode::UNIMPLEMENTED_COMMAND)
});
let command_result = match matches.subcommand_name() {
Some(name) => match name {
"root" => commands::root::RootCommand::new().run(),
_ => std::process::exit(exitcode::UNIMPLEMENTED_COMMAND),
},
_ => {
match app.print_help() {
Ok(_) => std::process::exit(exitcode::OK),
Err(_) => std::process::exit(exitcode::ABORT),
};
}
};
match command_result {
Ok(_) => std::process::exit(exitcode::OK),
Err(e) => e.exit(),
}
}