2 use crate::revlog::{Node, NodePrefix}; |
2 use crate::revlog::{Node, NodePrefix}; |
3 use crate::revlog::{Revlog, RevlogError}; |
3 use crate::revlog::{Revlog, RevlogError}; |
4 use crate::utils::hg_path::HgPath; |
4 use crate::utils::hg_path::HgPath; |
5 use crate::utils::SliceExt; |
5 use crate::utils::SliceExt; |
6 use crate::vfs::Vfs; |
6 use crate::vfs::Vfs; |
7 use crate::{Graph, GraphError, Revision, UncheckedRevision}; |
7 use crate::{ |
|
8 Graph, GraphError, Revision, RevlogOpenOptions, UncheckedRevision, |
|
9 }; |
8 |
10 |
9 /// A specialized `Revlog` to work with `manifest` data format. |
11 /// A specialized `Revlog` to work with `manifest` data format. |
10 pub struct Manifestlog { |
12 pub struct Manifestlog { |
11 /// The generic `revlog` format. |
13 /// The generic `revlog` format. |
12 revlog: Revlog, |
14 pub(crate) revlog: Revlog, |
13 } |
15 } |
14 |
16 |
15 impl Graph for Manifestlog { |
17 impl Graph for Manifestlog { |
16 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { |
18 fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { |
17 self.revlog.parents(rev) |
19 self.revlog.parents(rev) |
18 } |
20 } |
19 } |
21 } |
20 |
22 |
21 impl Manifestlog { |
23 impl Manifestlog { |
22 /// Open the `manifest` of a repository given by its root. |
24 /// Open the `manifest` of a repository given by its root. |
23 pub fn open(store_vfs: &Vfs, use_nodemap: bool) -> Result<Self, HgError> { |
25 pub fn open( |
24 let revlog = |
26 store_vfs: &Vfs, |
25 Revlog::open(store_vfs, "00manifest.i", None, use_nodemap)?; |
27 options: RevlogOpenOptions, |
|
28 ) -> Result<Self, HgError> { |
|
29 let revlog = Revlog::open(store_vfs, "00manifest.i", None, options)?; |
26 Ok(Self { revlog }) |
30 Ok(Self { revlog }) |
27 } |
31 } |
28 |
32 |
29 /// Return the `Manifest` for the given node ID. |
33 /// Return the `Manifest` for the given node ID. |
30 /// |
34 /// |