History

[commitgraph] Rename LexPosition to 'file::Position'

That way it's in line with 'graph::Position'

Sebastian Thiel committed 6 years ago

Commit 6f90bee1 parent d2eec1d6 files · +72 −55Browse files

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

Unified · Split

git-commitgraph/src/file/commit.rs+20−16
@@ -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+};
35 use byteorder::{BigEndian, ByteOrder};
46 use git_object::{borrowed, owned, SHA1_SIZE};
57 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+};
913
1014 quick_error! {
1115 #[derive(Debug)]
@@ -41,7 +45,7 @@ const EXTENDED_EDGES_MASK: u32 = 0x8000_0000; · 29 unmodified lines
4145
4246 pub struct Commit<'a> {
4347 file: &'a File,
44− lex_pos: LexPosition,
48+ lex_pos: file::Position,
4549 // We can parse the below fields lazily if needed.
4650 commit_timestamp: u64,
4751 generation: u32,
@@ -51,7 +55,7 @@ pub struct Commit<'a> { · 3 unmodified lines
5155 }
5256
5357 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 {
5559 let bytes = file.commit_data_bytes(pos);
5660 Commit {
5761 file,
@@ -79,7 +83,7 @@ impl<'a> Commit<'a> { · 21 unmodified lines
7983 self.generation
8084 }
8185
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 {
8387 // I didn't find a combinator approach that a) was as strict as ParentIterator, b) supported
8488 // fuse-after-first-error behavior, and b) was significantly shorter or more understandable
8589 // than ParentIterator. So here we are.
@@ -93,7 +97,7 @@ impl<'a> Commit<'a> { · 7 unmodified lines
9397 self.file.id_at(self.lex_pos)
9498 }
9599
96− pub fn parent1(&self) -> Result<Option<Position>, Error> {
100+ pub fn parent1(&self) -> Result<Option<graph::Position>, Error> {
97101 self.iter_parents().next().transpose()
98102 }
99103
@@ -131,7 +135,7 @@ pub struct ParentIterator<'a> { · 31 unmodified lines
131135 }
132136
133137 impl<'a> Iterator for ParentIterator<'a> {
134− type Item = Result<Position, Error>;
138+ type Item = Result<graph::Position, Error>;
135139
136140 fn next(&mut self) -> Option<Self::Item> {
137141 let state = std::mem::replace(&mut self.state, ParentIteratorState::Exhausted);
@@ -219,7 +223,7 @@ enum ParentIteratorState<'a> { · 81 unmodified lines
219223 #[derive(Clone, Copy, Debug)]
220224 enum ParentEdge {
221225 None,
222− GraphPosition(Position),
226+ GraphPosition(graph::Position),
223227 ExtraEdgeIndex(u32),
224228 }
225229
@@ -231,7 +235,7 @@ impl ParentEdge { · 5 unmodified lines
231235 if raw & EXTENDED_EDGES_MASK != 0 {
232236 ParentEdge::ExtraEdgeIndex(raw & !EXTENDED_EDGES_MASK)
233237 } else {
234− ParentEdge::GraphPosition(Position(raw))
238+ ParentEdge::GraphPosition(graph::Position(raw))
235239 }
236240 }
237241 }
@@ -239,16 +243,16 @@ impl ParentEdge { · 1 unmodified line
239243 const LAST_EXTENDED_EDGE_MASK: u32 = 0x8000_0000;
240244
241245 enum ExtraEdge {
242− Internal(Position),
243− Last(Position),
246+ Internal(graph::Position),
247+ Last(graph::Position),
244248 }
245249
246250 impl ExtraEdge {
247251 pub fn from_raw(raw: u32) -> Self {
248252 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))
250254 } else {
251− Self::Internal(Position(raw))
255+ Self::Internal(graph::Position(raw))
252256 }
253257 }
254258 }