Mercurial > public > mercurial-scm > hg-stable
view rust/rhg/src/commands/debugdata.rs @ 46504:252d1bdba33d
rhg: replace `map_*_error` functions with `From` impls
Differential Revision: https://phab.mercurial-scm.org/D9876
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Tue, 26 Jan 2021 20:31:26 +0100 |
parents | 3e2d539d0d1a |
children | a6e4e4650bac |
line wrap: on
line source
use crate::commands::Command; use crate::error::CommandError; use crate::ui::Ui; use hg::operations::{debug_data, DebugDataKind}; use hg::repo::Repo; use micro_timer::timed; 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> { #[timed] fn run(&self, ui: &Ui) -> Result<(), CommandError> { let repo = Repo::find()?; let data = debug_data(&repo, self.rev, self.kind) .map_err(|e| (e, self.rev))?; let mut stdout = ui.stdout_buffer(); stdout.write_all(&data)?; stdout.flush()?; Ok(()) } }