debugdata.rs
38 lines
| 1.1 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; | ||
Martin von Zweigbergk
|
r49978 | use crate::requirements; | ||
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 | }; | ||
Martin von Zweigbergk
|
r49978 | let use_nodemap = repo | ||
.requirements() | ||||
.contains(requirements::NODEMAP_REQUIREMENT); | ||||
Martin von Zweigbergk
|
r49980 | let revlog = | ||
Revlog::open(&repo.store_vfs(), index_file, None, use_nodemap)?; | ||||
Simon Sapin
|
r47162 | let rev = | ||
crate::revset::resolve_rev_number_or_hex_prefix(revset, &revlog)?; | ||||
let data = revlog.get_rev_data(rev)?; | ||||
Simon Sapin
|
r49373 | Ok(data.into_owned()) | ||
Antoine Cezar
|
r46098 | } | ||