Show More
@@ -9,7 +9,7 b' use std::path::PathBuf;' | |||||
9 |
|
9 | |||
10 | use crate::repo::Repo; |
|
10 | use crate::repo::Repo; | |
11 | use crate::revlog::changelog::Changelog; |
|
11 | use crate::revlog::changelog::Changelog; | |
12 | use crate::revlog::manifest::Manifest; |
|
12 | use crate::revlog::manifest::Manifestlog; | |
13 | use crate::revlog::path_encode::path_encode; |
|
13 | use crate::revlog::path_encode::path_encode; | |
14 | use crate::revlog::revlog::Revlog; |
|
14 | use crate::revlog::revlog::Revlog; | |
15 | use crate::revlog::revlog::RevlogError; |
|
15 | use crate::revlog::revlog::RevlogError; | |
@@ -43,7 +43,7 b" pub fn cat<'a>(" | |||||
43 | ) -> Result<CatOutput, RevlogError> { |
|
43 | ) -> Result<CatOutput, RevlogError> { | |
44 | let rev = crate::revset::resolve_single(revset, repo)?; |
|
44 | let rev = crate::revset::resolve_single(revset, repo)?; | |
45 | let changelog = Changelog::open(repo)?; |
|
45 | let changelog = Changelog::open(repo)?; | |
46 | let manifest = Manifest::open(repo)?; |
|
46 | let manifest = Manifestlog::open(repo)?; | |
47 | let changelog_entry = changelog.get_rev(rev)?; |
|
47 | let changelog_entry = changelog.get_rev(rev)?; | |
48 | let node = *changelog |
|
48 | let node = *changelog | |
49 | .node_from_rev(rev) |
|
49 | .node_from_rev(rev) |
@@ -10,7 +10,7 b' use crate::dirstate_tree::on_disk::{for_' | |||||
10 | use crate::errors::HgError; |
|
10 | use crate::errors::HgError; | |
11 | use crate::repo::Repo; |
|
11 | use crate::repo::Repo; | |
12 | use crate::revlog::changelog::Changelog; |
|
12 | use crate::revlog::changelog::Changelog; | |
13 |
use crate::revlog::manifest::{Manifest, Manifest |
|
13 | use crate::revlog::manifest::{Manifest, Manifestlog}; | |
14 | use crate::revlog::node::Node; |
|
14 | use crate::revlog::node::Node; | |
15 | use crate::revlog::revlog::RevlogError; |
|
15 | use crate::revlog::revlog::RevlogError; | |
16 | use crate::utils::hg_path::HgPath; |
|
16 | use crate::utils::hg_path::HgPath; | |
@@ -73,7 +73,7 b' pub fn list_rev_tracked_files(' | |||||
73 | ) -> Result<FilesForRev, RevlogError> { |
|
73 | ) -> Result<FilesForRev, RevlogError> { | |
74 | let rev = crate::revset::resolve_single(revset, repo)?; |
|
74 | let rev = crate::revset::resolve_single(revset, repo)?; | |
75 | let changelog = Changelog::open(repo)?; |
|
75 | let changelog = Changelog::open(repo)?; | |
76 | let manifest = Manifest::open(repo)?; |
|
76 | let manifest = Manifestlog::open(repo)?; | |
77 | let changelog_entry = changelog.get_rev(rev)?; |
|
77 | let changelog_entry = changelog.get_rev(rev)?; | |
78 | let manifest_node = |
|
78 | let manifest_node = | |
79 | Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; |
|
79 | Node::from_hex_for_repo(&changelog_entry.manifest_node()?)?; | |
@@ -81,7 +81,7 b' pub fn list_rev_tracked_files(' | |||||
81 | Ok(FilesForRev(manifest_entry)) |
|
81 | Ok(FilesForRev(manifest_entry)) | |
82 | } |
|
82 | } | |
83 |
|
83 | |||
84 |
pub struct FilesForRev(Manifest |
|
84 | pub struct FilesForRev(Manifest); | |
85 |
|
85 | |||
86 | impl FilesForRev { |
|
86 | impl FilesForRev { | |
87 | pub fn iter(&self) -> impl Iterator<Item = &HgPath> { |
|
87 | pub fn iter(&self) -> impl Iterator<Item = &HgPath> { |
@@ -5,12 +5,12 b' use crate::revlog::Revision;' | |||||
5 | use crate::utils::hg_path::HgPath; |
|
5 | use crate::utils::hg_path::HgPath; | |
6 |
|
6 | |||
7 | /// A specialized `Revlog` to work with `manifest` data format. |
|
7 | /// A specialized `Revlog` to work with `manifest` data format. | |
8 | pub struct Manifest { |
|
8 | pub struct Manifestlog { | |
9 | /// The generic `revlog` format. |
|
9 | /// The generic `revlog` format. | |
10 | revlog: Revlog, |
|
10 | revlog: Revlog, | |
11 | } |
|
11 | } | |
12 |
|
12 | |||
13 | impl Manifest { |
|
13 | impl Manifestlog { | |
14 | /// Open the `manifest` of a repository given by its root. |
|
14 | /// Open the `manifest` of a repository given by its root. | |
15 | pub fn open(repo: &Repo) -> Result<Self, RevlogError> { |
|
15 | pub fn open(repo: &Repo) -> Result<Self, RevlogError> { | |
16 | let revlog = Revlog::open(repo, "00manifest.i", None)?; |
|
16 | let revlog = Revlog::open(repo, "00manifest.i", None)?; | |
@@ -18,31 +18,25 b' impl Manifest {' | |||||
18 | } |
|
18 | } | |
19 |
|
19 | |||
20 | /// Return the `ManifestEntry` of a given node id. |
|
20 | /// Return the `ManifestEntry` of a given node id. | |
21 | pub fn get_node( |
|
21 | pub fn get_node(&self, node: NodePrefix) -> Result<Manifest, RevlogError> { | |
22 | &self, |
|
|||
23 | node: NodePrefix, |
|
|||
24 | ) -> Result<ManifestEntry, RevlogError> { |
|
|||
25 | let rev = self.revlog.get_node_rev(node)?; |
|
22 | let rev = self.revlog.get_node_rev(node)?; | |
26 | self.get_rev(rev) |
|
23 | self.get_rev(rev) | |
27 | } |
|
24 | } | |
28 |
|
25 | |||
29 | /// Return the `ManifestEntry` of a given node revision. |
|
26 | /// Return the `ManifestEntry` of a given node revision. | |
30 | pub fn get_rev( |
|
27 | pub fn get_rev(&self, rev: Revision) -> Result<Manifest, RevlogError> { | |
31 | &self, |
|
|||
32 | rev: Revision, |
|
|||
33 | ) -> Result<ManifestEntry, RevlogError> { |
|
|||
34 | let bytes = self.revlog.get_rev_data(rev)?; |
|
28 | let bytes = self.revlog.get_rev_data(rev)?; | |
35 |
Ok(Manifest |
|
29 | Ok(Manifest { bytes }) | |
36 | } |
|
30 | } | |
37 | } |
|
31 | } | |
38 |
|
32 | |||
39 | /// `Manifest` entry which knows how to interpret the `manifest` data bytes. |
|
33 | /// `Manifestlog` entry which knows how to interpret the `manifest` data bytes. | |
40 | #[derive(Debug)] |
|
34 | #[derive(Debug)] | |
41 |
pub struct Manifest |
|
35 | pub struct Manifest { | |
42 | bytes: Vec<u8>, |
|
36 | bytes: Vec<u8>, | |
43 | } |
|
37 | } | |
44 |
|
38 | |||
45 |
impl Manifest |
|
39 | impl Manifest { | |
46 | /// Return an iterator over the lines of the entry. |
|
40 | /// Return an iterator over the lines of the entry. | |
47 | pub fn lines(&self) -> impl Iterator<Item = &[u8]> { |
|
41 | pub fn lines(&self) -> impl Iterator<Item = &[u8]> { | |
48 | self.bytes |
|
42 | self.bytes |
General Comments 0
You need to be logged in to leave comments.
Login now