##// END OF EJS Templates
rust-changelog: introducing an intermediate `ChangelogEntry`...
rust-changelog: introducing an intermediate `ChangelogEntry` Before this change, client code needing to extract, e.g, the Node ID and the description from a changeset had no other choice than calling both `entry_for_rev()` and `data_for_rev()`. This duplicates some (limited) computation, and more importantly imposes bad hygiene for client code: at some point of developement, the client code would have to pass over both entry and data in its internal layers, which at some point of development would raise the question whether they are consistent. We introduce the intermediate `ChangelogEntry` from which both conversion to the generic `RevlogEntry` and extraction of `ChangelogRevisionData` are possible. It might grow some convenience methods in the future. We keep the `data_for_rev()` method of `Changelog` for compatibility, pointing users at the more powerful alternative.

File last commit:

r50808:c15b415d default
r51268:841b13e6 default
Show More
debugdata.rs
71 lines | 2.0 KiB | application/rls-services+xml | RustLexer
use crate::error::CommandError;
use clap::Arg;
use clap::ArgGroup;
use hg::operations::{debug_data, DebugDataKind};
pub const HELP_TEXT: &str = "
Dump the contents of a data file revision
";
pub fn args() -> clap::Command {
clap::command!("debugdata")
.arg(
Arg::new("changelog")
.help("open changelog")
.short('c')
.action(clap::ArgAction::SetTrue),
)
.arg(
Arg::new("manifest")
.help("open manifest")
.short('m')
.action(clap::ArgAction::SetTrue),
)
.group(
ArgGroup::new("revlog")
.args(&["changelog", "manifest"])
.required(true),
)
.arg(
Arg::new("rev")
.help("revision")
.required(true)
.value_name("REV"),
)
.about(HELP_TEXT)
}
#[logging_timer::time("trace")]
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let args = invocation.subcommand_args;
let rev = args
.get_one::<String>("rev")
.expect("rev should be a required argument");
let kind = match (
args.get_one::<bool>("changelog").unwrap(),
args.get_one::<bool>("manifest").unwrap(),
) {
(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")
}
};
let repo = invocation.repo?;
if repo.has_narrow() {
return Err(CommandError::unsupported(
"support for ellipsis nodes is missing and repo has narrow enabled",
));
}
let data = debug_data(repo, rev, kind).map_err(|e| (e, rev.as_ref()))?;
let mut stdout = invocation.ui.stdout_buffer();
stdout.write_all(&data)?;
stdout.flush()?;
Ok(())
}