History

[commitgraph] Rename CommitData -> Commit.

Conor Davis committed 6 years ago

Commit d8c20071 parent 7c405ab5 files · +18 −18Browse files

Showing the changes to git-commitgraph/src (5 of 5 files). Show all

Unified · Split

5 files
  1. git-commitgraph/src/graph/access.rs +4 −4
  2. git-commitgraph/src/graph_file/access.rs +4 −4
  3. git-commitgraph/src/graph_file/commit.rs +8 −8
  4. git-commitgraph/src/graph_file/mod.rs +1 −1
  5. git-commitgraph/src/lib.rs +1 −1
git-commitgraph/src/graph/access.rs+4−4
@@ -1,15 +1,15 @@
11 use crate::graph::GraphPosition;
22 use crate::graph_file::{GraphFile, LexPosition};
3−use crate::{CommitData, Graph};
3+use crate::{Commit, Graph};
44 use git_object::borrowed;
55
66 impl Graph {
7− pub fn commit_at(&self, pos: GraphPosition) -> CommitData<'_> {
7+ pub fn commit_at(&self, pos: GraphPosition) -> Commit<'_> {
88 let r = self.lookup_by_pos(pos);
99 r.file.commit_at(r.lex_pos)
1010 }
1111
12− pub fn commit_by_id(&self, id: borrowed::Id<'_>) -> Option<CommitData<'_>> {
12+ pub fn commit_by_id(&self, id: borrowed::Id<'_>) -> Option<Commit<'_>> {
1313 let r = self.lookup_by_id(id)?;
1414 Some(r.file.commit_at(r.lex_pos))
1515 }
@@ -20,7 +20,7 @@ impl Graph { · 4 unmodified lines
2020 }
2121
2222 /// Iterate over commits in unsorted order.
23− pub fn iter_commits(&self) -> impl Iterator<Item = CommitData<'_>> {
23+ pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>> {
2424 self.files.iter().flat_map(|file| file.iter_commits())
2525 }
2626
git-commitgraph/src/graph_file/access.rs+4−4
@@ -1,5 +1,5 @@
11 use crate::graph_file::{GraphFile, LexPosition, COMMIT_DATA_ENTRY_SIZE};
2−use crate::CommitData;
2+use crate::Commit;
33 use git_object::{borrowed, HashKind, SHA1_SIZE};
44 use std::convert::{TryFrom, TryInto};
55 use std::fmt::{Debug, Formatter};
@@ -13,8 +13,8 @@ impl GraphFile { · 7 unmodified lines
1313 /// # Panics
1414 ///
1515 /// Panics if `pos` is out of bounds.
16− pub fn commit_at(&self, pos: LexPosition) -> CommitData<'_> {
17− CommitData::new(self, pos)
16+ pub fn commit_at(&self, pos: LexPosition) -> Commit<'_> {
17+ Commit::new(self, pos)
1818 }
1919
2020 pub fn hash_kind(&self) -> HashKind {
@@ -49,7 +49,7 @@ impl GraphFile { · 28 unmodified lines
4949 .map(|bytes| borrowed::Id::try_from(bytes).expect("20 bytes SHA1 to be alright"))
5050 }
5151
52− pub fn iter_commits(&self) -> impl Iterator<Item = CommitData<'_>> {
52+ pub fn iter_commits(&self) -> impl Iterator<Item = Commit<'_>> {
5353 (0..self.num_commits()).map(move |i| self.commit_at(LexPosition(i)))
5454 }
5555
git-commitgraph/src/graph_file/commit.rsrenamed from git-commitgraph/src/graph_file/commit_data.rs+8−8
@@ -39,7 +39,7 @@ quick_error! { · 38 unmodified lines
3939 const NO_PARENT: u32 = 0x7000_0000;
4040 const EXTENDED_EDGES_MASK: u32 = 0x8000_0000;
4141
42−pub struct CommitData<'a> {
42+pub struct Commit<'a> {
4343 file: &'a GraphFile,
4444 lex_pos: LexPosition,
4545 // We can parse the below fields lazily if needed.
@@ -50,10 +50,10 @@ pub struct CommitData<'a> { · 4 unmodified lines
5050 root_tree_id: borrowed::Id<'a>,
5151 }
5252
53−impl<'a> CommitData<'a> {
53+impl<'a> Commit<'a> {
5454 pub(crate) fn new(file: &'a GraphFile, pos: LexPosition) -> Self {
5555 let bytes = file.commit_data_bytes(pos);
56− CommitData {
56+ Commit {
5757 file,
5858 lex_pos: pos,
5959 root_tree_id: borrowed::Id::try_from(&bytes[..SHA1_SIZE]).expect("20 bytes SHA1 to be alright"),
@@ -102,11 +102,11 @@ impl<'a> CommitData<'a> { · 42 unmodified lines
102102 }
103103 }
104104
105−impl<'a> Debug for CommitData<'a> {
105+impl<'a> Debug for Commit<'a> {
106106 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
107107 write!(
108108 f,
109− "CommitData {{ id: {}, lex_pos: {}, generation: {}, root_tree_oid: {}, parent1: {:?}, parent2: {:?} }}",
109+ "Commit {{ id: {}, lex_pos: {}, generation: {}, root_tree_id: {}, parent1: {:?}, parent2: {:?} }}",
110110 self.id(),
111111 self.lex_pos,
112112 self.generation(),
@@ -117,16 +117,16 @@ impl<'a> Debug for CommitData<'a> { · 4 unmodified lines
117117 }
118118 }
119119
120−impl<'a> Eq for CommitData<'a> {}
120+impl<'a> Eq for Commit<'a> {}
121121
122−impl<'a> PartialEq for CommitData<'a> {
122+impl<'a> PartialEq for Commit<'a> {
123123 fn eq(&self, other: &Self) -> bool {
124124 self.file as *const GraphFile == other.file as *const GraphFile && self.lex_pos == other.lex_pos
125125 }
126126 }
127127
128128 pub struct ParentIterator<'a> {
129− commit_data: &'a CommitData<'a>,
129+ commit_data: &'a Commit<'a>,
130130 state: ParentIteratorState<'a>,
131131 }
132132
git-commitgraph/src/graph_file/mod.rs+1−1
@@ -4,7 +4,7 @@ use std::ops::Range; · 3 unmodified lines
44 use std::path::PathBuf;
55
66 mod access;
7−pub mod commit_data;
7+pub mod commit;
88 mod init;
99
1010 pub use init::Error;
git-commitgraph/src/lib.rs+1−1
@@ -5,6 +5,6 @@ pub mod graph; · 4 unmodified lines
55 pub mod graph_file;
66
77 pub use graph::{Graph, GraphPosition};
8−pub use graph_file::commit_data::CommitData;
8+pub use graph_file::commit::Commit;
99
1010 pub const MAX_COMMITS: u32 = (1 << 30) + (1 << 29) + (1 << 28) - 1;