comparison rust/hg-core/src/operations/debugdata.rs @ 46167:8a4914397d02

rust: introduce Repo and Vfs types for filesystem abstraction This is similar to the corresponding Python classes. Repo represents a repository and knows the path to the `.hg` directory, the `store` directory, and the working directory. Separating these will enable supporting the share extension. A Vfs is created from a Repo for one of these three directories. It has filesystem access APIs that take a relative std::path::Path as a parameter. Differential Revision: https://phab.mercurial-scm.org/D9596
author Simon Sapin <simon.sapin@octobus.net>
date Mon, 14 Dec 2020 16:33:15 +0100
parents dca9cb99971c
children 645ee7225fab
comparison
equal deleted inserted replaced
46166:c511fef30290 46167:8a4914397d02
3 // Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net> 3 // Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net>
4 // 4 //
5 // This software may be used and distributed according to the terms of the 5 // This software may be used and distributed according to the terms of the
6 // GNU General Public License version 2 or any later version. 6 // GNU General Public License version 2 or any later version.
7 7
8 use std::path::Path; 8 use crate::repo::Repo;
9
10 use crate::revlog::revlog::{Revlog, RevlogError}; 9 use crate::revlog::revlog::{Revlog, RevlogError};
11 use crate::revlog::NodePrefix; 10 use crate::revlog::NodePrefix;
12 use crate::revlog::Revision; 11 use crate::revlog::Revision;
13 12
14 /// Kind of data to debug 13 /// Kind of data to debug
77 } 76 }
78 } 77 }
79 78
80 /// Dump the contents data of a revision. 79 /// Dump the contents data of a revision.
81 pub fn debug_data( 80 pub fn debug_data(
82 root: &Path, 81 repo: &Repo,
83 rev: &str, 82 rev: &str,
84 kind: DebugDataKind, 83 kind: DebugDataKind,
85 ) -> Result<Vec<u8>, DebugDataError> { 84 ) -> Result<Vec<u8>, DebugDataError> {
86 let index_file = match kind { 85 let index_file = match kind {
87 DebugDataKind::Changelog => root.join(".hg/store/00changelog.i"), 86 DebugDataKind::Changelog => "00changelog.i",
88 DebugDataKind::Manifest => root.join(".hg/store/00manifest.i"), 87 DebugDataKind::Manifest => "00manifest.i",
89 }; 88 };
90 let revlog = Revlog::open(&index_file, None)?; 89 let revlog = Revlog::open(repo, index_file, None)?;
91 90
92 let data = match rev.parse::<Revision>() { 91 let data = match rev.parse::<Revision>() {
93 Ok(rev) => revlog.get_rev_data(rev)?, 92 Ok(rev) => revlog.get_rev_data(rev)?,
94 _ => { 93 _ => {
95 let node = NodePrefix::from_hex(&rev) 94 let node = NodePrefix::from_hex(&rev)