##// END OF EJS Templates
tests: use sha256line.py instead of /dev/random in test-censor.t (issue6858)...
tests: use sha256line.py instead of /dev/random in test-censor.t (issue6858) Sometimes the systems that run our test suite don't have enough entropy and they cannot produce target file of the expected size using /dev/random, which results in test failures. Switching to /dev/urandom would give us way more available data at the cost of it being less "random", but we don't really need to use entropy for this task at all, since we only care if the file size after compression is big enough to not be stored inline in the revlog. So let's use something that we already have used to generate this kind of data in other tests.

File last commit:

r52013:532e74ad default
r52255:e7be2ddf stable
Show More
debugdata.rs
71 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 a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099
pub const HELP_TEXT: &str = "
Dump the contents of a data file revision
";
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 pub fn args() -> clap::Command {
clap::command!("debugdata")
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 .arg(
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 Arg::new("changelog")
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 .help("open changelog")
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 .short('c')
.action(clap::ArgAction::SetTrue),
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 )
.arg(
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 Arg::new("manifest")
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 .help("open manifest")
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 .short('m')
.action(clap::ArgAction::SetTrue),
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 )
.group(
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 ArgGroup::new("revlog")
Raphaël Gomès
rust: run a clippy pass with the latest stable version...
r52013 .args(["changelog", "manifest"])
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 .required(true),
)
.arg(
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 Arg::new("rev")
Simon Sapin
rhg: Move subcommand CLI arguments definitions to respective modules...
r47251 .help("revision")
.required(true)
.value_name("REV"),
)
.about(HELP_TEXT)
}
Raphaël Gomès
rust: use `logging_timer` instead of `micro_timer`...
r50808 #[logging_timer::time("trace")]
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
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 .get_one::<String>("rev")
Simon Sapin
rhg: replace command structs with functions...
r47250 .expect("rev should be a required argument");
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 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")
}
};
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",
));
}
Raphaël Gomès
rhg: upgrade `clap` dependency...
r50534 let data = debug_data(repo, rev, kind).map_err(|e| (e, rev.as_ref()))?;
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 }