##// END OF EJS Templates
dirstate: test a `hg status` raced by a `hg remove`...
dirstate: test a `hg status` raced by a `hg remove` This shows that `rhg` is misbehaving here.

File last commit:

r50808:c15b415d default
r51119:e30b9e43 stable
Show More
debugdata.rs
70 lines | 2.0 KiB | application/rls-services+xml | RustLexer
Simon Sapin
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field...
r47163 use crate::error::CommandError;
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 use clap::Arg;
use clap::ArgGroup;
Simon Sapin
rhg: replace `map_*_error` functions with `From` impls...
r47165 use hg::operations::{debug_data, DebugDataKind};
Antoine Cezar
rhg: Add debug timing...
r46101 use micro_timer::timed;
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099
pub const HELP_TEXT: &str = "
Dump the contents of a data file revision
";
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 pub fn args() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("debugdata")
.arg(
Arg::with_name("changelog")
.help("open changelog")
.short("-c")
.long("--changelog"),
)
.arg(
Arg::with_name("manifest")
.help("open manifest")
.short("-m")
.long("--manifest"),
)
.group(
ArgGroup::with_name("")
.args(&["changelog", "manifest"])
.required(true),
)
.arg(
Arg::with_name("rev")
.help("revision")
.required(true)
.value_name("REV"),
)
.about(HELP_TEXT)
}
Simon Sapin
rhg: replace command structs with functions...
r47250 #[timed]
Simon Sapin
rhg: Group values passed to every sub-command into a struct...
r47334 pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let args = invocation.subcommand_args;
Simon Sapin
rhg: replace command structs with functions...
r47250 let rev = args
.value_of("rev")
.expect("rev should be a required argument");
let kind =
match (args.is_present("changelog"), args.is_present("manifest")) {
(true, false) => DebugDataKind::Changelog,
(false, true) => DebugDataKind::Manifest,
(true, true) => {
unreachable!("Should not happen since options are exclusive")
}
(false, false) => {
unreachable!("Should not happen since options are required")
}
};
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099
Simon Sapin
rhg: Move `Repo` object creation into `main()`...
r47335 let repo = invocation.repo?;
Raphaël Gomès
rhg: fallback in `debugdata` if repo has `narrow`...
r50375 if repo.has_narrow() {
return Err(CommandError::unsupported(
"support for ellipsis nodes is missing and repo has narrow enabled",
));
}
Simon Sapin
rhg: Move `Repo` object creation into `main()`...
r47335 let data = debug_data(repo, rev, kind).map_err(|e| (e, rev))?;
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099
Simon Sapin
rhg: Group values passed to every sub-command into a struct...
r47334 let mut stdout = invocation.ui.stdout_buffer();
Simon Sapin
rhg: replace command structs with functions...
r47250 stdout.write_all(&data)?;
stdout.flush()?;
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099
Simon Sapin
rhg: replace command structs with functions...
r47250 Ok(())
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099 }