debugdata.rs
33 lines
| 911 B
| 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; | ||
Antoine Cezar
|
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. | ||||
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 | }; | ||
Simon Sapin
|
r46782 | let revlog = Revlog::open(repo, index_file, None)?; | ||
Simon Sapin
|
r47162 | let rev = | ||
crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?; | ||||
let data = revlog.get_rev_data(rev)?; | ||||
Simon Sapin
|
r46751 | Ok(data) | ||
Antoine Cezar
|
r46098 | } | ||