comparison rust/hg-core/src/revlog/changelog.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 cc6faec62cb7
children 645ee7225fab
comparison
equal deleted inserted replaced
46166:c511fef30290 46167:8a4914397d02
1 use crate::repo::Repo;
1 use crate::revlog::revlog::{Revlog, RevlogError}; 2 use crate::revlog::revlog::{Revlog, RevlogError};
2 use crate::revlog::NodePrefixRef; 3 use crate::revlog::NodePrefixRef;
3 use crate::revlog::Revision; 4 use crate::revlog::Revision;
4 use std::path::Path;
5 5
6 /// A specialized `Revlog` to work with `changelog` data format. 6 /// A specialized `Revlog` to work with `changelog` data format.
7 pub struct Changelog { 7 pub struct Changelog {
8 /// The generic `revlog` format. 8 /// The generic `revlog` format.
9 revlog: Revlog, 9 revlog: Revlog,
10 } 10 }
11 11
12 impl Changelog { 12 impl Changelog {
13 /// Open the `changelog` of a repository given by its root. 13 /// Open the `changelog` of a repository given by its root.
14 pub fn open(root: &Path) -> Result<Self, RevlogError> { 14 pub fn open(repo: &Repo) -> Result<Self, RevlogError> {
15 let index_file = root.join(".hg/store/00changelog.i"); 15 let revlog = Revlog::open(repo, "00changelog.i", None)?;
16 let revlog = Revlog::open(&index_file, None)?;
17 Ok(Self { revlog }) 16 Ok(Self { revlog })
18 } 17 }
19 18
20 /// Return the `ChangelogEntry` a given node id. 19 /// Return the `ChangelogEntry` a given node id.
21 pub fn get_node( 20 pub fn get_node(