debugdata.rs
33 lines
| 924 B
| application/rls-services+xml
|
RustLexer
|
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. | ||||
|
r46782 | use crate::repo::Repo; | ||
|
r46098 | use crate::revlog::revlog::{Revlog, RevlogError}; | ||
/// Kind of data to debug | ||||
#[derive(Debug, Copy, Clone)] | ||||
pub enum DebugDataKind { | ||||
Changelog, | ||||
Manifest, | ||||
} | ||||
/// Dump the contents data of a revision. | ||||
|
r46751 | pub fn debug_data( | ||
|
r46782 | repo: &Repo, | ||
|
r47162 | revset: &str, | ||
|
r46098 | kind: DebugDataKind, | ||
|
r47166 | ) -> Result<Vec<u8>, RevlogError> { | ||
|
r46751 | let index_file = match kind { | ||
|
r46782 | DebugDataKind::Changelog => "00changelog.i", | ||
DebugDataKind::Manifest => "00manifest.i", | ||||
|
r46751 | }; | ||
|
r46782 | let revlog = Revlog::open(repo, index_file, None)?; | ||
|
r47162 | let rev = | ||
crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?; | ||||
let data = revlog.get_rev_data(rev)?; | ||||
|
r49373 | Ok(data.into_owned()) | ||
|
r46098 | } | ||