Showing the changes to git-commitgraph/src (4 of 22 files). Show all
Unified · Split
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use crate::file::{self, commit::Commit, File, COMMIT_DATA_ENTRY_SIZE}; |
| 2 | 2 | use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE; |
| 3 | −use git_object::{borrowed, HashKind}; | |
| 3 | +use git_object::HashKind; | |
| 4 | 4 | use std::{ |
| 5 | 5 | convert::{TryFrom, TryInto}, |
| 6 | 6 | fmt::{Debug, Formatter}, |
| @@ -35,7 +35,7 @@ impl File { · 28 unmodified lines | ||
| 35 | 35 | /// Returns 20 bytes sha1 at the given index in our list of (sorted) sha1 hashes. |
| 36 | 36 | /// The position ranges from 0 to self.num_commits() |
| 37 | 37 | // copied from git-odb/src/pack/index/access.rs |
| 38 | − pub fn id_at(&self, pos: file::Position) -> borrowed::Id<'_> { | |
| 38 | + pub fn id_at(&self, pos: file::Position) -> git_hash::borrowed::Id<'_> { | |
| 39 | 39 | assert!( |
| 40 | 40 | pos.0 < self.num_commits(), |
| 41 | 41 | "expected lexigraphical position less than {}, got {}", |
| @@ -47,16 +47,16 @@ impl File { · 5 unmodified lines | ||
| 47 | 47 | .try_into() |
| 48 | 48 | .expect("an architecture able to hold 32 bits of integer"); |
| 49 | 49 | let start = self.oid_lookup_offset + (pos * SHA1_SIZE); |
| 50 | − borrowed::Id::try_from(&self.data[start..start + SHA1_SIZE]).expect("20 bytes SHA1 to be alright") | |
| 50 | + git_hash::borrowed::Id::try_from(&self.data[start..start + SHA1_SIZE]).expect("20 bytes SHA1 to be alright") | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /// Return an iterator over all object hashes stored in the base graph. |
| 54 | − pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> { | |
| 54 | + pub fn iter_base_graph_ids(&self) -> impl Iterator<Item = git_hash::borrowed::Id<'_>> { | |
| 55 | 55 | let start = self.base_graphs_list_offset.unwrap_or(0); |
| 56 | 56 | let base_graphs_list = &self.data[start..start + (SHA1_SIZE * usize::from(self.base_graph_count))]; |
| 57 | 57 | base_graphs_list |
| 58 | 58 | .chunks(SHA1_SIZE) |
| 59 | − .map(|bytes| borrowed::Id::try_from(bytes).expect("20 bytes SHA1 to be alright")) | |
| 59 | + .map(|bytes| git_hash::borrowed::Id::try_from(bytes).expect("20 bytes SHA1 to be alright")) | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /// return an iterator over all commits in this file. |
| @@ -65,13 +65,13 @@ impl File { · 2 unmodified lines | ||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /// Return an iterator over all object hashes stored in this file. |
| 68 | − pub fn iter_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> { | |
| 68 | + pub fn iter_ids(&self) -> impl Iterator<Item = git_hash::borrowed::Id<'_>> { | |
| 69 | 69 | (0..self.num_commits()).map(move |i| self.id_at(file::Position(i))) |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /// Translate the given object hash to its position within this file, if present. |
| 73 | 73 | // copied from git-odb/src/pack/index/access.rs |
| 74 | − pub fn lookup(&self, id: borrowed::Id<'_>) -> Option<file::Position> { | |
| 74 | + pub fn lookup(&self, id: git_hash::borrowed::Id<'_>) -> Option<file::Position> { | |
| 75 | 75 | let first_byte = usize::from(id.first_byte()); |
| 76 | 76 | let mut upper_bound = self.fan[first_byte]; |
| 77 | 77 | let mut lower_bound = if first_byte != 0 { self.fan[first_byte - 1] } else { 0 }; |
| @@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines | ||
| 5 | 5 | }; |
| 6 | 6 | use byteorder::{BigEndian, ByteOrder}; |
| 7 | 7 | use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE; |
| 8 | −use git_object::{borrowed, owned}; | |
| 8 | +use git_object::owned; | |
| 9 | 9 | use std::{ |
| 10 | 10 | convert::{TryFrom, TryInto}, |
| 11 | 11 | fmt::{Debug, Formatter}, |
| @@ -40,7 +40,7 @@ pub struct Commit<'a> { · 28 unmodified lines | ||
| 40 | 40 | generation: u32, |
| 41 | 41 | parent1: ParentEdge, |
| 42 | 42 | parent2: ParentEdge, |
| 43 | − root_tree_id: borrowed::Id<'a>, | |
| 43 | + root_tree_id: git_hash::borrowed::Id<'a>, | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | impl<'a> Commit<'a> { |
| @@ -49,7 +49,7 @@ impl<'a> Commit<'a> { · 2 unmodified lines | ||
| 49 | 49 | Commit { |
| 50 | 50 | file, |
| 51 | 51 | pos, |
| 52 | − root_tree_id: borrowed::Id::try_from(&bytes[..SHA1_SIZE]).expect("20 bytes SHA1 to be alright"), | |
| 52 | + root_tree_id: git_hash::borrowed::Id::try_from(&bytes[..SHA1_SIZE]).expect("20 bytes SHA1 to be alright"), | |
| 53 | 53 | parent1: ParentEdge::from_raw(BigEndian::read_u32(&bytes[SHA1_SIZE..SHA1_SIZE + 4])), |
| 54 | 54 | parent2: ParentEdge::from_raw(BigEndian::read_u32(&bytes[SHA1_SIZE + 4..SHA1_SIZE + 8])), |
| 55 | 55 | generation: BigEndian::read_u32(&bytes[SHA1_SIZE + 8..SHA1_SIZE + 12]) >> 2, |
| @@ -84,7 +84,7 @@ impl<'a> Commit<'a> { · 28 unmodified lines | ||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /// Returns the hash of this commit. |
| 87 | − pub fn id(&self) -> borrowed::Id<'a> { | |
| 87 | + pub fn id(&self) -> git_hash::borrowed::Id<'a> { | |
| 88 | 88 | self.file.id_at(self.pos) |
| 89 | 89 | } |
| 90 | 90 | |
| @@ -99,7 +99,7 @@ impl<'a> Commit<'a> { · 8 unmodified lines | ||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /// Return the hash of the tree this commit points to. |
| 102 | − pub fn root_tree_id(&self) -> borrowed::Id<'a> { | |
| 102 | + pub fn root_tree_id(&self) -> git_hash::borrowed::Id<'a> { | |
| 103 | 103 | self.root_tree_id |
| 104 | 104 | } |
| 105 | 105 | } |
| @@ -5,7 +5,7 @@ use crate::{ · 4 unmodified lines | ||
| 5 | 5 | }; |
| 6 | 6 | use bstr::ByteSlice; |
| 7 | 7 | use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE; |
| 8 | −use git_object::{borrowed, owned}; | |
| 8 | +use git_object::owned; | |
| 9 | 9 | use std::{ |
| 10 | 10 | cmp::{max, min}, |
| 11 | 11 | collections::HashMap, |
| @@ -58,8 +58,9 @@ pub struct Outcome { · 46 unmodified lines | ||
| 58 | 58 | /// Verification |
| 59 | 59 | impl File { |
| 60 | 60 | /// Returns the trailing checksum over the entire content of this file. |
| 61 | − pub fn checksum(&self) -> borrowed::Id<'_> { | |
| 62 | − borrowed::Id::try_from(&self.data[self.data.len() - SHA1_SIZE..]).expect("file to be large enough for a hash") | |
| 61 | + pub fn checksum(&self) -> git_hash::borrowed::Id<'_> { | |
| 62 | + git_hash::borrowed::Id::try_from(&self.data[self.data.len() - SHA1_SIZE..]) | |
| 63 | + .expect("file to be large enough for a hash") | |
| 63 | 64 | } |
| 64 | 65 | |
| 65 | 66 | /// Traverse all [commits][file::Commit] stored in this file and call `processor(commit) -> Result<(), Error>` on it. |
| @@ -74,7 +75,7 @@ impl File { · 8 unmodified lines | ||
| 74 | 75 | .map_err(|(actual, expected)| Error::Mismatch { actual, expected })?; |
| 75 | 76 | verify_split_chain_filename_hash(&self.path, self.checksum()).map_err(Error::Filename)?; |
| 76 | 77 | |
| 77 | − let null_id = borrowed::Id::null_sha1(); | |
| 78 | + let null_id = git_hash::borrowed::Id::null_sha1(); | |
| 78 | 79 | |
| 79 | 80 | let mut stats = Outcome { |
| 80 | 81 | max_generation: 0, |
| @@ -85,7 +86,7 @@ impl File { · 4 unmodified lines | ||
| 85 | 86 | }; |
| 86 | 87 | |
| 87 | 88 | // TODO: Verify self.fan values as we go. |
| 88 | − let mut prev_id: borrowed::Id<'a> = null_id; | |
| 89 | + let mut prev_id: git_hash::borrowed::Id<'a> = null_id; | |
| 89 | 90 | for commit in self.iter_commits() { |
| 90 | 91 | if commit.id() <= prev_id { |
| 91 | 92 | if commit.id() == null_id { |
| @@ -157,7 +158,10 @@ impl File { · 65 unmodified lines | ||
| 157 | 158 | |
| 158 | 159 | /// If the given path's filename matches "graph-{hash}.graph", check that `hash` matches the |
| 159 | 160 | /// expected hash. |
| 160 | −fn verify_split_chain_filename_hash(path: impl AsRef<Path>, expected: borrowed::Id<'_>) -> Result<(), String> { | |
| 161 | +fn verify_split_chain_filename_hash( | |
| 162 | + path: impl AsRef<Path>, | |
| 163 | + expected: git_hash::borrowed::Id<'_>, | |
| 164 | +) -> Result<(), String> { | |
| 161 | 165 | let path = path.as_ref(); |
| 162 | 166 | path.file_name() |
| 163 | 167 | .and_then(|filename| filename.to_str()) |
| @@ -2,7 +2,6 @@ use crate::{ · 1 unmodified line | ||
| 2 | 2 | file::{self, Commit, File}, |
| 3 | 3 | graph::{self, Graph}, |
| 4 | 4 | }; |
| 5 | −use git_object::borrowed; | |
| 6 | 5 | |
| 7 | 6 | /// Access |
| 8 | 7 | impl Graph { |
| @@ -16,7 +15,7 @@ impl Graph { · 7 unmodified lines | ||
| 16 | 15 | } |
| 17 | 16 | |
| 18 | 17 | /// Returns the commit matching the given `id`. |
| 19 | − pub fn commit_by_id(&self, id: borrowed::Id<'_>) -> Option<Commit<'_>> { | |
| 18 | + pub fn commit_by_id(&self, id: git_hash::borrowed::Id<'_>) -> Option<Commit<'_>> { | |
| 20 | 19 | let r = self.lookup_by_id(id)?; |
| 21 | 20 | Some(r.file.commit_at(r.file_pos)) |
| 22 | 21 | } |
| @@ -25,7 +24,7 @@ impl Graph { · 2 unmodified lines | ||
| 25 | 24 | /// |
| 26 | 25 | /// # Panics |
| 27 | 26 | /// If `pos` is greater or equal to [`num_commits()`][Graph::num_commits()]. |
| 28 | − pub fn id_at(&self, pos: graph::Position) -> borrowed::Id<'_> { | |
| 27 | + pub fn id_at(&self, pos: graph::Position) -> git_hash::borrowed::Id<'_> { | |
| 29 | 28 | let r = self.lookup_by_pos(pos); |
| 30 | 29 | r.file.id_at(r.pos) |
| 31 | 30 | } |
| @@ -36,12 +35,12 @@ impl Graph { · 4 unmodified lines | ||
| 36 | 35 | } |
| 37 | 36 | |
| 38 | 37 | /// Iterate over commit IDs in unsorted order. |
| 39 | − pub fn iter_ids(&self) -> impl Iterator<Item = borrowed::Id<'_>> { | |
| 38 | + pub fn iter_ids(&self) -> impl Iterator<Item = git_hash::borrowed::Id<'_>> { | |
| 40 | 39 | self.files.iter().flat_map(|file| file.iter_ids()) |
| 41 | 40 | } |
| 42 | 41 | |
| 43 | 42 | /// Translate the given `id` to its position in the file. |
| 44 | − pub fn lookup(&self, id: borrowed::Id<'_>) -> Option<graph::Position> { | |
| 43 | + pub fn lookup(&self, id: git_hash::borrowed::Id<'_>) -> Option<graph::Position> { | |
| 45 | 44 | Some(self.lookup_by_id(id)?.graph_pos) |
| 46 | 45 | } |
| 47 | 46 | |
| @@ -53,7 +52,7 @@ impl Graph { · 5 unmodified lines | ||
| 53 | 52 | |
| 54 | 53 | /// Access fundamentals |
| 55 | 54 | impl Graph { |
| 56 | − pub(crate) fn lookup_by_id(&self, id: borrowed::Id<'_>) -> Option<LookupByIdResult<'_>> { | |
| 55 | + pub(crate) fn lookup_by_id(&self, id: git_hash::borrowed::Id<'_>) -> Option<LookupByIdResult<'_>> { | |
| 57 | 56 | let mut current_file_start = 0; |
| 58 | 57 | for file in &self.files { |
| 59 | 58 | if let Some(lex_pos) = file.lookup(id) { |