Show More
@@ -4,7 +4,7 b' use crate::revlog::{Node, NodePrefix};' | |||
|
4 | 4 | use crate::revlog::{Revlog, RevlogEntry, RevlogError}; |
|
5 | 5 | use crate::utils::hg_path::HgPath; |
|
6 | 6 | use crate::vfs::Vfs; |
|
7 | use crate::UncheckedRevision; | |
|
7 | use crate::{Graph, GraphError, UncheckedRevision}; | |
|
8 | 8 | use itertools::Itertools; |
|
9 | 9 | use std::ascii::escape_default; |
|
10 | 10 | use std::borrow::Cow; |
@@ -76,6 +76,12 b' impl Changelog {' | |||
|
76 | 76 | } |
|
77 | 77 | } |
|
78 | 78 | |
|
79 | impl Graph for Changelog { | |
|
80 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { | |
|
81 | self.revlog.parents(rev) | |
|
82 | } | |
|
83 | } | |
|
84 | ||
|
79 | 85 | /// A specialized `RevlogEntry` for `changelog` data format |
|
80 | 86 | /// |
|
81 | 87 | /// This is a `RevlogEntry` with the added semantics that the associated |
@@ -9,6 +9,8 b' use crate::revlog::{Revlog, RevlogError}' | |||
|
9 | 9 | use crate::utils::files::get_path_from_bytes; |
|
10 | 10 | use crate::utils::hg_path::HgPath; |
|
11 | 11 | use crate::utils::SliceExt; |
|
12 | use crate::Graph; | |
|
13 | use crate::GraphError; | |
|
12 | 14 | use crate::UncheckedRevision; |
|
13 | 15 | use std::path::PathBuf; |
|
14 | 16 | |
@@ -18,6 +20,12 b' pub struct Filelog {' | |||
|
18 | 20 | revlog: Revlog, |
|
19 | 21 | } |
|
20 | 22 | |
|
23 | impl Graph for Filelog { | |
|
24 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { | |
|
25 | self.revlog.parents(rev) | |
|
26 | } | |
|
27 | } | |
|
28 | ||
|
21 | 29 | impl Filelog { |
|
22 | 30 | pub fn open_vfs( |
|
23 | 31 | store_vfs: &crate::vfs::Vfs<'_>, |
@@ -6,7 +6,7 b' use byteorder::{BigEndian, ByteOrder};' | |||
|
6 | 6 | use crate::errors::HgError; |
|
7 | 7 | use crate::revlog::node::Node; |
|
8 | 8 | use crate::revlog::{Revision, NULL_REVISION}; |
|
9 | use crate::UncheckedRevision; | |
|
9 | use crate::{Graph, GraphError, RevlogIndex, UncheckedRevision}; | |
|
10 | 10 | |
|
11 | 11 | pub const INDEX_ENTRY_SIZE: usize = 64; |
|
12 | 12 | |
@@ -97,6 +97,23 b' impl Debug for Index {' | |||
|
97 | 97 | } |
|
98 | 98 | } |
|
99 | 99 | |
|
100 | impl Graph for Index { | |
|
101 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { | |
|
102 | let err = || GraphError::ParentOutOfRange(rev); | |
|
103 | match self.get_entry(rev) { | |
|
104 | Some(entry) => { | |
|
105 | // The C implementation checks that the parents are valid | |
|
106 | // before returning | |
|
107 | Ok([ | |
|
108 | self.check_revision(entry.p1()).ok_or_else(err)?, | |
|
109 | self.check_revision(entry.p2()).ok_or_else(err)?, | |
|
110 | ]) | |
|
111 | } | |
|
112 | None => Ok([NULL_REVISION, NULL_REVISION]), | |
|
113 | } | |
|
114 | } | |
|
115 | } | |
|
116 | ||
|
100 | 117 | impl Index { |
|
101 | 118 | /// Create an index from bytes. |
|
102 | 119 | /// Calculate the start of each entry when is_inline is true. |
@@ -4,7 +4,7 b' use crate::revlog::{Revlog, RevlogError}' | |||
|
4 | 4 | use crate::utils::hg_path::HgPath; |
|
5 | 5 | use crate::utils::SliceExt; |
|
6 | 6 | use crate::vfs::Vfs; |
|
7 | use crate::{Revision, UncheckedRevision}; | |
|
7 | use crate::{Graph, GraphError, Revision, UncheckedRevision}; | |
|
8 | 8 | |
|
9 | 9 | /// A specialized `Revlog` to work with `manifest` data format. |
|
10 | 10 | pub struct Manifestlog { |
@@ -12,6 +12,12 b' pub struct Manifestlog {' | |||
|
12 | 12 | revlog: Revlog, |
|
13 | 13 | } |
|
14 | 14 | |
|
15 | impl Graph for Manifestlog { | |
|
16 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { | |
|
17 | self.revlog.parents(rev) | |
|
18 | } | |
|
19 | } | |
|
20 | ||
|
15 | 21 | impl Manifestlog { |
|
16 | 22 | /// Open the `manifest` of a repository given by its root. |
|
17 | 23 | pub fn open(store_vfs: &Vfs, use_nodemap: bool) -> Result<Self, HgError> { |
@@ -182,6 +182,12 b' pub struct Revlog {' | |||
|
182 | 182 | nodemap: Option<nodemap::NodeTree>, |
|
183 | 183 | } |
|
184 | 184 | |
|
185 | impl Graph for Revlog { | |
|
186 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError> { | |
|
187 | self.index.parents(rev) | |
|
188 | } | |
|
189 | } | |
|
190 | ||
|
185 | 191 | impl Revlog { |
|
186 | 192 | /// Open a revlog index file. |
|
187 | 193 | /// |
General Comments 0
You need to be logged in to leave comments.
Login now