History

[commitgraph] refactor Graph, Position, and access module

Sebastian Thiel committed 6 years ago

Commit 3c8640e1 parent 2ed00378 files · +47 −32Browse files

Showing the changes to git-commitgraph/src/file/commit.rs (1 of 8 files). Show all

Unified · Split

git-commitgraph/src/file/commit.rs+10−10
@@ -1,5 +1,5 @@
11 use crate::file::{File, LexPosition};
2−use crate::graph::GraphPosition;
2+use crate::graph::Position;
33 use byteorder::{BigEndian, ByteOrder};
44 use git_object::{borrowed, owned, SHA1_SIZE};
55 use quick_error::quick_error;
@@ -79,7 +79,7 @@ impl<'a> Commit<'a> { · 73 unmodified lines
7979 self.generation
8080 }
8181
82− pub fn iter_parents(&'a self) -> impl Iterator<Item = Result<GraphPosition, Error>> + 'a {
82+ pub fn iter_parents(&'a self) -> impl Iterator<Item = Result<Position, Error>> + 'a {
8383 // I didn't find a combinator approach that a) was as strict as ParentIterator, b) supported
8484 // fuse-after-first-error behavior, and b) was significantly shorter or more understandable
8585 // than ParentIterator. So here we are.
@@ -93,7 +93,7 @@ impl<'a> Commit<'a> { · 7 unmodified lines
9393 self.file.id_at(self.lex_pos)
9494 }
9595
96− pub fn parent1(&self) -> Result<Option<GraphPosition>, Error> {
96+ pub fn parent1(&self) -> Result<Option<Position>, Error> {
9797 self.iter_parents().next().transpose()
9898 }
9999
@@ -131,7 +131,7 @@ pub struct ParentIterator<'a> { · 31 unmodified lines
131131 }
132132
133133 impl<'a> Iterator for ParentIterator<'a> {
134− type Item = Result<GraphPosition, Error>;
134+ type Item = Result<Position, Error>;
135135
136136 fn next(&mut self) -> Option<Self::Item> {
137137 let state = std::mem::replace(&mut self.state, ParentIteratorState::Exhausted);
@@ -219,7 +219,7 @@ enum ParentIteratorState<'a> { · 81 unmodified lines
219219 #[derive(Clone, Copy, Debug)]
220220 enum ParentEdge {
221221 None,
222− GraphPosition(GraphPosition),
222+ GraphPosition(Position),
223223 ExtraEdgeIndex(u32),
224224 }
225225
@@ -231,7 +231,7 @@ impl ParentEdge { · 5 unmodified lines
231231 if raw & EXTENDED_EDGES_MASK != 0 {
232232 ParentEdge::ExtraEdgeIndex(raw & !EXTENDED_EDGES_MASK)
233233 } else {
234− ParentEdge::GraphPosition(GraphPosition(raw))
234+ ParentEdge::GraphPosition(Position(raw))
235235 }
236236 }
237237 }
@@ -239,16 +239,16 @@ impl ParentEdge { · 1 unmodified line
239239 const LAST_EXTENDED_EDGE_MASK: u32 = 0x8000_0000;
240240
241241 enum ExtraEdge {
242− Internal(GraphPosition),
243− Last(GraphPosition),
242+ Internal(Position),
243+ Last(Position),
244244 }
245245
246246 impl ExtraEdge {
247247 pub fn from_raw(raw: u32) -> Self {
248248 if raw & LAST_EXTENDED_EDGE_MASK != 0 {
249− Self::Last(GraphPosition(raw & !LAST_EXTENDED_EDGE_MASK))
249+ Self::Last(Position(raw & !LAST_EXTENDED_EDGE_MASK))
250250 } else {
251− Self::Internal(GraphPosition(raw))
251+ Self::Internal(Position(raw))
252252 }
253253 }
254254 }