debugdata.rs
42 lines
| 1.1 KiB
| application/rls-services+xml
|
RustLexer
|
r47163 | use crate::error::CommandError; | ||
|
r46099 | use crate::ui::Ui; | ||
|
r47250 | use clap::ArgMatches; | ||
|
r47213 | use hg::config::Config; | ||
|
r47165 | use hg::operations::{debug_data, DebugDataKind}; | ||
|
r46782 | use hg::repo::Repo; | ||
|
r46101 | use micro_timer::timed; | ||
|
r46099 | |||
pub const HELP_TEXT: &str = " | ||||
Dump the contents of a data file revision | ||||
"; | ||||
|
r47250 | #[timed] | ||
pub fn run( | ||||
ui: &Ui, | ||||
config: &Config, | ||||
args: &ArgMatches, | ||||
) -> Result<(), CommandError> { | ||||
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") | ||||
} | ||||
}; | ||||
|
r46099 | |||
|
r47250 | let repo = Repo::find(config)?; | ||
let data = debug_data(&repo, rev, kind).map_err(|e| (e, rev))?; | ||||
|
r46099 | |||
|
r47250 | let mut stdout = ui.stdout_buffer(); | ||
stdout.write_all(&data)?; | ||||
stdout.flush()?; | ||||
|
r46099 | |||
|
r47250 | Ok(()) | ||
|
r46099 | } | ||