Showing the changes to git-commitgraph/src/file/commit.rs (1 of 8 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | |||
| 1 | use crate::file::{File, LexPosition}; | 1 | use crate::file::{File, LexPosition}; |
| 2 | use crate::graph::GraphPosition; | 2 | use crate::graph::Position; |
| 3 | use byteorder::{BigEndian, ByteOrder}; | 3 | use byteorder::{BigEndian, ByteOrder}; |
| 4 | use git_object::{borrowed, owned, SHA1_SIZE}; | 4 | use git_object::{borrowed, owned, SHA1_SIZE}; |
| 5 | use quick_error::quick_error; | 5 | use quick_error::quick_error; |
| @@ -79,7 +79,7 @@ impl<'a> Commit<'a> { · 73 unmodified lines | |||
| 79 | self.generation | 79 | self.generation |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 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 { |
| 83 | // I didn't find a combinator approach that a) was as strict as ParentIterator, b) supported | 83 | // I didn't find a combinator approach that a) was as strict as ParentIterator, b) supported |
| 84 | // fuse-after-first-error behavior, and b) was significantly shorter or more understandable | 84 | // fuse-after-first-error behavior, and b) was significantly shorter or more understandable |
| 85 | // than ParentIterator. So here we are. | 85 | // than ParentIterator. So here we are. |
| @@ -93,7 +93,7 @@ impl<'a> Commit<'a> { · 7 unmodified lines | |||
| 93 | self.file.id_at(self.lex_pos) | 93 | self.file.id_at(self.lex_pos) |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | pub fn parent1(&self) -> Result<Option<GraphPosition>, Error> { | 96 | pub fn parent1(&self) -> Result<Option<Position>, Error> { |
| 97 | self.iter_parents().next().transpose() | 97 | self.iter_parents().next().transpose() |
| 98 | } | 98 | } |
| 99 | 99 | ||
| @@ -131,7 +131,7 @@ pub struct ParentIterator<'a> { · 31 unmodified lines | |||
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | impl<'a> Iterator for ParentIterator<'a> { | 133 | impl<'a> Iterator for ParentIterator<'a> { |
| 134 | type Item = Result<GraphPosition, Error>; | 134 | type Item = Result<Position, Error>; |
| 135 | 135 | ||
| 136 | fn next(&mut self) -> Option<Self::Item> { | 136 | fn next(&mut self) -> Option<Self::Item> { |
| 137 | let state = std::mem::replace(&mut self.state, ParentIteratorState::Exhausted); | 137 | let state = std::mem::replace(&mut self.state, ParentIteratorState::Exhausted); |
| @@ -219,7 +219,7 @@ enum ParentIteratorState<'a> { · 81 unmodified lines | |||
| 219 | #[derive(Clone, Copy, Debug)] | 219 | #[derive(Clone, Copy, Debug)] |
| 220 | enum ParentEdge { | 220 | enum ParentEdge { |
| 221 | None, | 221 | None, |
| 222 | GraphPosition(GraphPosition), | 222 | GraphPosition(Position), |
| 223 | ExtraEdgeIndex(u32), | 223 | ExtraEdgeIndex(u32), |
| 224 | } | 224 | } |
| 225 | 225 | ||
| @@ -231,7 +231,7 @@ impl ParentEdge { · 5 unmodified lines | |||
| 231 | if raw & EXTENDED_EDGES_MASK != 0 { | 231 | if raw & EXTENDED_EDGES_MASK != 0 { |
| 232 | ParentEdge::ExtraEdgeIndex(raw & !EXTENDED_EDGES_MASK) | 232 | ParentEdge::ExtraEdgeIndex(raw & !EXTENDED_EDGES_MASK) |
| 233 | } else { | 233 | } else { |
| 234 | ParentEdge::GraphPosition(GraphPosition(raw)) | 234 | ParentEdge::GraphPosition(Position(raw)) |
| 235 | } | 235 | } |
| 236 | } | 236 | } |
| 237 | } | 237 | } |
| @@ -239,16 +239,16 @@ impl ParentEdge { · 1 unmodified line | |||
| 239 | const LAST_EXTENDED_EDGE_MASK: u32 = 0x8000_0000; | 239 | const LAST_EXTENDED_EDGE_MASK: u32 = 0x8000_0000; |
| 240 | 240 | ||
| 241 | enum ExtraEdge { | 241 | enum ExtraEdge { |
| 242 | Internal(GraphPosition), | 242 | Internal(Position), |
| 243 | Last(GraphPosition), | 243 | Last(Position), |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | impl ExtraEdge { | 246 | impl ExtraEdge { |
| 247 | pub fn from_raw(raw: u32) -> Self { | 247 | pub fn from_raw(raw: u32) -> Self { |
| 248 | if raw & LAST_EXTENDED_EDGE_MASK != 0 { | 248 | 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)) |
| 250 | } else { | 250 | } else { |
| 251 | Self::Internal(GraphPosition(raw)) | 251 | Self::Internal(Position(raw)) |
| 252 | } | 252 | } |
| 253 | } | 253 | } |
| 254 | } | 254 | } |