That way it's in line with 'graph::Position'
Showing the changes to git-commitgraph/src/file/commit.rs (1 of 6 files). Show all
Unified · Split
| @@ -1,11 +1,15 @@ | ||
| 1 | −use crate::file::{File, LexPosition}; | |
| 2 | −use crate::graph::Position; | |
| 1 | +use crate::{ | |
| 2 | + file::{self, File}, | |
| 3 | + graph, | |
| 4 | +}; | |
| 3 | 5 | use byteorder::{BigEndian, ByteOrder}; |
| 4 | 6 | use git_object::{borrowed, owned, SHA1_SIZE}; |
| 5 | 7 | use quick_error::quick_error; |
| 6 | −use std::convert::{TryFrom, TryInto}; | |
| 7 | −use std::fmt::{Debug, Formatter}; | |
| 8 | −use std::slice::Chunks; | |
| 8 | +use std::{ | |
| 9 | + convert::{TryFrom, TryInto}, | |
| 10 | + fmt::{Debug, Formatter}, | |
| 11 | + slice::Chunks, | |
| 12 | +}; | |
| 9 | 13 | |
| 10 | 14 | quick_error! { |
| 11 | 15 | #[derive(Debug)] |
| @@ -41,7 +45,7 @@ const EXTENDED_EDGES_MASK: u32 = 0x8000_0000; · 29 unmodified lines | ||
| 41 | 45 | |
| 42 | 46 | pub struct Commit<'a> { |
| 43 | 47 | file: &'a File, |
| 44 | − lex_pos: LexPosition, | |
| 48 | + lex_pos: file::Position, | |
| 45 | 49 | // We can parse the below fields lazily if needed. |
| 46 | 50 | commit_timestamp: u64, |
| 47 | 51 | generation: u32, |
| @@ -51,7 +55,7 @@ pub struct Commit<'a> { · 3 unmodified lines | ||
| 51 | 55 | } |
| 52 | 56 | |
| 53 | 57 | impl<'a> Commit<'a> { |
| 54 | − pub(crate) fn new(file: &'a File, pos: LexPosition) -> Self { | |
| 58 | + pub(crate) fn new(file: &'a File, pos: file::Position) -> Self { | |
| 55 | 59 | let bytes = file.commit_data_bytes(pos); |
| 56 | 60 | Commit { |
| 57 | 61 | file, |
| @@ -79,7 +83,7 @@ impl<'a> Commit<'a> { · 21 unmodified lines | ||
| 79 | 83 | self.generation |
| 80 | 84 | } |
| 81 | 85 | |
| 82 | − pub fn iter_parents(&'a self) -> impl Iterator<Item = Result<Position, Error>> + 'a { | |
| 86 | + pub fn iter_parents(&'a self) -> impl Iterator<Item = Result<graph::Position, Error>> + 'a { | |
| 83 | 87 | // I didn't find a combinator approach that a) was as strict as ParentIterator, b) supported |
| 84 | 88 | // fuse-after-first-error behavior, and b) was significantly shorter or more understandable |
| 85 | 89 | // than ParentIterator. So here we are. |
| @@ -93,7 +97,7 @@ impl<'a> Commit<'a> { · 7 unmodified lines | ||
| 93 | 97 | self.file.id_at(self.lex_pos) |
| 94 | 98 | } |
| 95 | 99 | |
| 96 | − pub fn parent1(&self) -> Result<Option<Position>, Error> { | |
| 100 | + pub fn parent1(&self) -> Result<Option<graph::Position>, Error> { | |
| 97 | 101 | self.iter_parents().next().transpose() |
| 98 | 102 | } |
| 99 | 103 | |
| @@ -131,7 +135,7 @@ pub struct ParentIterator<'a> { · 31 unmodified lines | ||
| 131 | 135 | } |
| 132 | 136 | |
| 133 | 137 | impl<'a> Iterator for ParentIterator<'a> { |
| 134 | − type Item = Result<Position, Error>; | |
| 138 | + type Item = Result<graph::Position, Error>; | |
| 135 | 139 | |
| 136 | 140 | fn next(&mut self) -> Option<Self::Item> { |
| 137 | 141 | let state = std::mem::replace(&mut self.state, ParentIteratorState::Exhausted); |
| @@ -219,7 +223,7 @@ enum ParentIteratorState<'a> { · 81 unmodified lines | ||
| 219 | 223 | #[derive(Clone, Copy, Debug)] |
| 220 | 224 | enum ParentEdge { |
| 221 | 225 | None, |
| 222 | − GraphPosition(Position), | |
| 226 | + GraphPosition(graph::Position), | |
| 223 | 227 | ExtraEdgeIndex(u32), |
| 224 | 228 | } |
| 225 | 229 | |
| @@ -231,7 +235,7 @@ impl ParentEdge { · 5 unmodified lines | ||
| 231 | 235 | if raw & EXTENDED_EDGES_MASK != 0 { |
| 232 | 236 | ParentEdge::ExtraEdgeIndex(raw & !EXTENDED_EDGES_MASK) |
| 233 | 237 | } else { |
| 234 | − ParentEdge::GraphPosition(Position(raw)) | |
| 238 | + ParentEdge::GraphPosition(graph::Position(raw)) | |
| 235 | 239 | } |
| 236 | 240 | } |
| 237 | 241 | } |
| @@ -239,16 +243,16 @@ impl ParentEdge { · 1 unmodified line | ||
| 239 | 243 | const LAST_EXTENDED_EDGE_MASK: u32 = 0x8000_0000; |
| 240 | 244 | |
| 241 | 245 | enum ExtraEdge { |
| 242 | − Internal(Position), | |
| 243 | − Last(Position), | |
| 246 | + Internal(graph::Position), | |
| 247 | + Last(graph::Position), | |
| 244 | 248 | } |
| 245 | 249 | |
| 246 | 250 | impl ExtraEdge { |
| 247 | 251 | pub fn from_raw(raw: u32) -> Self { |
| 248 | 252 | if raw & LAST_EXTENDED_EDGE_MASK != 0 { |
| 249 | − Self::Last(Position(raw & !LAST_EXTENDED_EDGE_MASK)) | |
| 253 | + Self::Last(graph::Position(raw & !LAST_EXTENDED_EDGE_MASK)) | |
| 250 | 254 | } else { |
| 251 | − Self::Internal(Position(raw)) | |
| 255 | + Self::Internal(graph::Position(raw)) | |
| 252 | 256 | } |
| 253 | 257 | } |
| 254 | 258 | } |