Show More
@@ -50,7 +50,7 b" pub fn cat<'a>(" | |||||
50 | found_any = true; |
|
50 | found_any = true; | |
51 | let file_log = repo.filelog(manifest_file)?; |
|
51 | let file_log = repo.filelog(manifest_file)?; | |
52 | let file_node = Node::from_hex_for_repo(node_bytes)?; |
|
52 | let file_node = Node::from_hex_for_repo(node_bytes)?; | |
53 |
let entry = file_log. |
|
53 | let entry = file_log.data_for_node(file_node)?; | |
54 | bytes.extend(entry.data()?) |
|
54 | bytes.extend(entry.data()?) | |
55 | } |
|
55 | } | |
56 | } |
|
56 | } |
@@ -336,26 +336,29 b' impl Repo {' | |||||
336 | self.manifestlog.get_mut_or_init(self) |
|
336 | self.manifestlog.get_mut_or_init(self) | |
337 | } |
|
337 | } | |
338 |
|
338 | |||
339 | /// Returns the manifest of the given node ID |
|
339 | /// Returns the manifest of the *changeset* with the given node ID | |
340 | pub fn manifest_for_node( |
|
340 | pub fn manifest_for_node( | |
341 | &self, |
|
341 | &self, | |
342 | node: impl Into<NodePrefix>, |
|
342 | node: impl Into<NodePrefix>, | |
343 | ) -> Result<Manifest, RevlogError> { |
|
343 | ) -> Result<Manifest, RevlogError> { | |
344 |
self.manifestlog()?. |
|
344 | self.manifestlog()?.data_for_node( | |
345 | self.changelog()? |
|
345 | self.changelog()? | |
346 |
. |
|
346 | .data_for_node(node.into())? | |
347 | .manifest_node()? |
|
347 | .manifest_node()? | |
348 | .into(), |
|
348 | .into(), | |
349 | ) |
|
349 | ) | |
350 | } |
|
350 | } | |
351 |
|
351 | |||
352 | /// Returns the manifest of the given revision |
|
352 | /// Returns the manifest of the *changeset* with the given revision number | |
353 | pub fn manifest_for_rev( |
|
353 | pub fn manifest_for_rev( | |
354 | &self, |
|
354 | &self, | |
355 | revision: Revision, |
|
355 | revision: Revision, | |
356 | ) -> Result<Manifest, RevlogError> { |
|
356 | ) -> Result<Manifest, RevlogError> { | |
357 |
self.manifestlog()?. |
|
357 | self.manifestlog()?.data_for_node( | |
358 | self.changelog()?.get_rev(revision)?.manifest_node()?.into(), |
|
358 | self.changelog()? | |
|
359 | .data_for_rev(revision)? | |||
|
360 | .manifest_node()? | |||
|
361 | .into(), | |||
359 | ) |
|
362 | ) | |
360 | } |
|
363 | } | |
361 |
|
364 |
@@ -17,17 +17,17 b' impl Changelog {' | |||||
17 | Ok(Self { revlog }) |
|
17 | Ok(Self { revlog }) | |
18 | } |
|
18 | } | |
19 |
|
19 | |||
20 |
/// Return the `ChangelogEntry` |
|
20 | /// Return the `ChangelogEntry` for the given node ID. | |
21 |
pub fn |
|
21 | pub fn data_for_node( | |
22 | &self, |
|
22 | &self, | |
23 | node: NodePrefix, |
|
23 | node: NodePrefix, | |
24 | ) -> Result<ChangelogEntry, RevlogError> { |
|
24 | ) -> Result<ChangelogEntry, RevlogError> { | |
25 | let rev = self.revlog.rev_from_node(node)?; |
|
25 | let rev = self.revlog.rev_from_node(node)?; | |
26 |
self. |
|
26 | self.data_for_rev(rev) | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 |
/// Return the `ChangelogEntry` of |
|
29 | /// Return the `ChangelogEntry` of the given revision number. | |
30 |
pub fn |
|
30 | pub fn data_for_rev( | |
31 | &self, |
|
31 | &self, | |
32 | rev: Revision, |
|
32 | rev: Revision, | |
33 | ) -> Result<ChangelogEntry, RevlogError> { |
|
33 | ) -> Result<ChangelogEntry, RevlogError> { |
@@ -26,17 +26,17 b' impl Filelog {' | |||||
26 |
|
26 | |||
27 | /// The given node ID is that of the file as found in a manifest, not of a |
|
27 | /// The given node ID is that of the file as found in a manifest, not of a | |
28 | /// changeset. |
|
28 | /// changeset. | |
29 |
pub fn |
|
29 | pub fn data_for_node( | |
30 | &self, |
|
30 | &self, | |
31 | file_node: impl Into<NodePrefix>, |
|
31 | file_node: impl Into<NodePrefix>, | |
32 | ) -> Result<FilelogEntry, RevlogError> { |
|
32 | ) -> Result<FilelogEntry, RevlogError> { | |
33 | let file_rev = self.revlog.rev_from_node(file_node.into())?; |
|
33 | let file_rev = self.revlog.rev_from_node(file_node.into())?; | |
34 |
self. |
|
34 | self.data_for_rev(file_rev) | |
35 | } |
|
35 | } | |
36 |
|
36 | |||
37 | /// The given revision is that of the file as found in a manifest, not of a |
|
37 | /// The given revision is that of the file as found in a manifest, not of a | |
38 | /// changeset. |
|
38 | /// changeset. | |
39 |
pub fn |
|
39 | pub fn data_for_rev( | |
40 | &self, |
|
40 | &self, | |
41 | file_rev: Revision, |
|
41 | file_rev: Revision, | |
42 | ) -> Result<FilelogEntry, RevlogError> { |
|
42 | ) -> Result<FilelogEntry, RevlogError> { |
@@ -18,14 +18,31 b' impl Manifestlog {' | |||||
18 | Ok(Self { revlog }) |
|
18 | Ok(Self { revlog }) | |
19 | } |
|
19 | } | |
20 |
|
20 | |||
21 |
/// Return the `Manifest |
|
21 | /// Return the `Manifest` for the given node ID. | |
22 | pub fn get_node(&self, node: NodePrefix) -> Result<Manifest, RevlogError> { |
|
22 | /// | |
|
23 | /// Note: this is a node ID in the manifestlog, typically found through | |||
|
24 | /// `ChangelogEntry::manifest_node`. It is *not* the node ID of any | |||
|
25 | /// changeset. | |||
|
26 | /// | |||
|
27 | /// See also `Repo::manifest_for_node` | |||
|
28 | pub fn data_for_node( | |||
|
29 | &self, | |||
|
30 | node: NodePrefix, | |||
|
31 | ) -> Result<Manifest, RevlogError> { | |||
23 | let rev = self.revlog.rev_from_node(node)?; |
|
32 | let rev = self.revlog.rev_from_node(node)?; | |
24 |
self. |
|
33 | self.data_for_rev(rev) | |
25 | } |
|
34 | } | |
26 |
|
35 | |||
27 |
/// Return the `Manifest |
|
36 | /// Return the `Manifest` of a given revision number. | |
28 | pub fn get_rev(&self, rev: Revision) -> Result<Manifest, RevlogError> { |
|
37 | /// | |
|
38 | /// Note: this is a revision number in the manifestlog, *not* of any | |||
|
39 | /// changeset. | |||
|
40 | /// | |||
|
41 | /// See also `Repo::manifest_for_rev` | |||
|
42 | pub fn data_for_rev( | |||
|
43 | &self, | |||
|
44 | rev: Revision, | |||
|
45 | ) -> Result<Manifest, RevlogError> { | |||
29 | let bytes = self.revlog.get_rev_data(rev)?; |
|
46 | let bytes = self.revlog.get_rev_data(rev)?; | |
30 | Ok(Manifest { bytes }) |
|
47 | Ok(Manifest { bytes }) | |
31 | } |
|
48 | } |
@@ -119,12 +119,14 b' impl Revlog {' | |||||
119 | self.index.is_empty() |
|
119 | self.index.is_empty() | |
120 | } |
|
120 | } | |
121 |
|
121 | |||
122 |
/// Returns the node ID for the given revision number, if it exists in this |
|
122 | /// Returns the node ID for the given revision number, if it exists in this | |
|
123 | /// revlog | |||
123 | pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { |
|
124 | pub fn node_from_rev(&self, rev: Revision) -> Option<&Node> { | |
124 | Some(self.index.get_entry(rev)?.hash()) |
|
125 | Some(self.index.get_entry(rev)?.hash()) | |
125 | } |
|
126 | } | |
126 |
|
127 | |||
127 |
/// Return the revision number for the given node ID, if it exists in this |
|
128 | /// Return the revision number for the given node ID, if it exists in this | |
|
129 | /// revlog | |||
128 | #[timed] |
|
130 | #[timed] | |
129 | pub fn rev_from_node( |
|
131 | pub fn rev_from_node( | |
130 | &self, |
|
132 | &self, |
@@ -270,7 +270,7 b' fn cat_file_is_modified(' | |||||
270 | .find_file(hg_path)? |
|
270 | .find_file(hg_path)? | |
271 | .expect("ambgious file not in p1"); |
|
271 | .expect("ambgious file not in p1"); | |
272 | let filelog = repo.filelog(hg_path)?; |
|
272 | let filelog = repo.filelog(hg_path)?; | |
273 |
let filelog_entry = filelog. |
|
273 | let filelog_entry = filelog.data_for_node(file_node).map_err(|_| { | |
274 | HgError::corrupted("filelog missing node from manifest") |
|
274 | HgError::corrupted("filelog missing node from manifest") | |
275 | })?; |
|
275 | })?; | |
276 | let contents_in_p1 = filelog_entry.data()?; |
|
276 | let contents_in_p1 = filelog_entry.data()?; |
General Comments 0
You need to be logged in to leave comments.
Login now