debugdata.rs
38 lines
| 1.0 KiB
| application/rls-services+xml
|
RustLexer
Antoine Cezar
|
r46098 | // debugdata.rs | ||
// | ||||
// Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net> | ||||
// | ||||
// This software may be used and distributed according to the terms of the | ||||
// GNU General Public License version 2 or any later version. | ||||
Simon Sapin
|
r46782 | use crate::repo::Repo; | ||
Raphaël Gomès
|
r50832 | use crate::revlog::{Revlog, RevlogError}; | ||
Antoine Cezar
|
r46098 | |||
/// Kind of data to debug | ||||
Raphaël Gomès
|
r52084 | #[derive(Debug, Copy, Clone, PartialEq, Eq)] | ||
Antoine Cezar
|
r46098 | pub enum DebugDataKind { | ||
Changelog, | ||||
Manifest, | ||||
} | ||||
/// Dump the contents data of a revision. | ||||
Simon Sapin
|
r46751 | pub fn debug_data( | ||
Simon Sapin
|
r46782 | repo: &Repo, | ||
Simon Sapin
|
r47162 | revset: &str, | ||
Antoine Cezar
|
r46098 | kind: DebugDataKind, | ||
Simon Sapin
|
r47166 | ) -> Result<Vec<u8>, RevlogError> { | ||
Simon Sapin
|
r46751 | let index_file = match kind { | ||
Simon Sapin
|
r46782 | DebugDataKind::Changelog => "00changelog.i", | ||
DebugDataKind::Manifest => "00manifest.i", | ||||
Simon Sapin
|
r46751 | }; | ||
Raphaël Gomès
|
r52084 | let revlog = Revlog::open( | ||
&repo.store_vfs(), | ||||
index_file, | ||||
None, | ||||
repo.default_revlog_options(kind == DebugDataKind::Changelog)?, | ||||
)?; | ||||
Simon Sapin
|
r47162 | let rev = | ||
crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?; | ||||
Raphaël Gomès
|
r51870 | let data = revlog.get_rev_data_for_checked_rev(rev)?; | ||
Simon Sapin
|
r49373 | Ok(data.into_owned()) | ||
Antoine Cezar
|
r46098 | } | ||