##// END OF EJS Templates
rust: Use the DisplayBytes trait in config printing...
rust: Use the DisplayBytes trait in config printing This is similar to `std::fmt::Display`, but for arbitrary bytes instead of Unicode. Writing to an abstract output stream helps avoid allocating intermediate `Vec<u8>` buffers. Differential Revision: https://phab.mercurial-scm.org/D9966

File last commit:

r47231:1a00a578 default
r47249:eace48b4 default
Show More
debugdata.rs
37 lines | 895 B | application/rls-services+xml | RustLexer
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099 use crate::commands::Command;
Simon Sapin
rust: remove `FooError` structs with only `kind: FooErrorKind` enum field...
r47163 use crate::error::CommandError;
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099 use crate::ui::Ui;
Simon Sapin
rhg: Parse system and user configuration at program start...
r47213 use hg::config::Config;
Simon Sapin
rhg: replace `map_*_error` functions with `From` impls...
r47165 use hg::operations::{debug_data, DebugDataKind};
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 use hg::repo::Repo;
Antoine Cezar
rhg: Add debug timing...
r46101 use micro_timer::timed;
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
";
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> {
Antoine Cezar
rhg: Add debug timing...
r46101 #[timed]
Simon Sapin
rhg: Parse system and user configuration at program start...
r47213 fn run(&self, ui: &Ui, config: &Config) -> Result<(), CommandError> {
let repo = Repo::find(config)?;
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 let data = debug_data(&repo, self.rev, self.kind)
Simon Sapin
rhg: replace `map_*_error` functions with `From` impls...
r47165 .map_err(|e| (e, self.rev))?;
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099
let mut stdout = ui.stdout_buffer();
stdout.write_all(&data)?;
stdout.flush()?;
Ok(())
}
}