debugdata.rs
36 lines
| 848 B
| application/rls-services+xml
|
RustLexer
|
r46099 | use crate::commands::Command; | ||
|
r47163 | use crate::error::CommandError; | ||
|
r46099 | use crate::ui::Ui; | ||
|
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 | ||||
"; | ||||
pub struct DebugDataCommand<'a> { | ||||
rev: &'a str, | ||||
kind: DebugDataKind, | ||||
} | ||||
impl<'a> DebugDataCommand<'a> { | ||||
pub fn new(rev: &'a str, kind: DebugDataKind) -> Self { | ||||
DebugDataCommand { rev, kind } | ||||
} | ||||
} | ||||
impl<'a> Command for DebugDataCommand<'a> { | ||||
|
r46101 | #[timed] | ||
|
r46099 | fn run(&self, ui: &Ui) -> Result<(), CommandError> { | ||
|
r46782 | let repo = Repo::find()?; | ||
let data = debug_data(&repo, self.rev, self.kind) | ||||
|
r47165 | .map_err(|e| (e, self.rev))?; | ||
|
r46099 | |||
let mut stdout = ui.stdout_buffer(); | ||||
stdout.write_all(&data)?; | ||||
stdout.flush()?; | ||||
Ok(()) | ||||
} | ||||
} | ||||