Skip to content

Commit

Permalink
Merge branch 'adjustments-for-cargo'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Feb 5, 2023
2 parents 961264e + ea76bf5 commit 7bba270
Show file tree
Hide file tree
Showing 91 changed files with 5,106 additions and 1,613 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ value = branch-override-by-include
git::lock::acquire::Fail::Immediately,
git::lock::acquire::Fail::Immediately,
)?
.commit(repo.committer().expect("pre-configured"))?;
.commit(repo.committer().transpose()?)?;

let dir = assure_git_agrees(expect, dir)?;
Ok(GitEnv { repo, dir })
Expand Down
8 changes: 4 additions & 4 deletions git-date/src/parse.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#[derive(thiserror::Error, Debug)]
#[derive(thiserror::Error, Debug, Clone)]
#[allow(missing_docs)]
pub enum Error {
#[error("Cannot represent times before UNIX epoch at timestamp {timestamp}")]
TooEarly { timestamp: i64 },
#[error("Could not convert a duration into a date")]
RelativeTimeConversion,
#[error("Date string can not be parsed")]
InvalidDateString,
InvalidDateString { input: String },
#[error("Dates past 2038 can not be represented.")]
InvalidDate(#[from] std::num::TryFromIntError),
#[error("Current time is missing.")]
#[error("Current time is missing but required to handle relative dates.")]
MissingCurrentTime,
}

Expand Down Expand Up @@ -56,7 +56,7 @@ pub(crate) mod function {
} else if let Some(time) = relative::parse(input, now).transpose()? {
Time::new(timestamp(time)?, time.offset().whole_seconds())
} else {
return Err(Error::InvalidDateString);
return Err(Error::InvalidDateString { input: input.into() });
})
}

Expand Down
2 changes: 1 addition & 1 deletion git-date/tests/time/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn git_default() {
fn invalid_dates_can_be_produced_without_current_time() {
assert!(matches!(
git_date::parse("foobar", None).unwrap_err(),
git_date::parse::Error::InvalidDateString
git_date::parse::Error::InvalidDateString { input } if input == "foobar"
));
}

Expand Down
1 change: 1 addition & 0 deletions git-features/src/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::io;

pub use prodash::{
messages::MessageLevel,
progress::Id,
progress::{Discard, DoOrDiscard, Either, Step, StepShared, ThroughputOnDrop, UNKNOWN},
unit, Progress, Unit,
};
Expand Down
39 changes: 36 additions & 3 deletions git-odb/src/store_impls/dynamic/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::{

///
pub mod integrity {
use std::marker::PhantomData;
use std::path::PathBuf;

use crate::pack;
Expand Down Expand Up @@ -81,6 +82,29 @@ pub mod integrity {
/// The provided progress instance.
pub progress: P,
}

/// The progress ids used in [`Store::verify_integrity()`][crate::Store::verify_integrity()].
///
/// Use this information to selectively extract the progress of interest in case the parent application has custom visualization.
#[derive(Debug, Copy, Clone)]
pub enum ProgressId {
/// Contains the path of the currently validated loose object database.
VerifyLooseObjectDbPath,
/// The root progress for all verification of an index. It doesn't contain any useful information itself.
VerifyIndex(PhantomData<git_pack::index::verify::integrity::ProgressId>),
/// The root progress for all verification of a multi-index. It doesn't contain any useful information itself.
VerifyMultiIndex(PhantomData<git_pack::multi_index::verify::integrity::ProgressId>),
}

impl From<ProgressId> for git_features::progress::Id {
fn from(v: ProgressId) -> Self {
match v {
ProgressId::VerifyLooseObjectDbPath => *b"VISP",
ProgressId::VerifyMultiIndex(_) => *b"VIMI",
ProgressId::VerifyIndex(_) => *b"VISI",
}
}
}
}

impl super::Store {
Expand Down Expand Up @@ -154,7 +178,10 @@ impl super::Store {
data,
options: options.clone(),
}),
progress.add_child_with_id("never shown", git_features::progress::UNKNOWN),
progress.add_child_with_id(
"verify index",
integrity::ProgressId::VerifyIndex(Default::default()).into(),
),
should_interrupt,
)?;
statistics.push(IndexStatistics {
Expand All @@ -177,7 +204,10 @@ impl super::Store {
}
};
let outcome = index.verify_integrity(
progress.add_child_with_id("never shown", git_features::progress::UNKNOWN),
progress.add_child_with_id(
"verify multi-index",
integrity::ProgressId::VerifyMultiIndex(Default::default()).into(),
),
should_interrupt,
options.clone(),
)?;
Expand Down Expand Up @@ -216,7 +246,10 @@ impl super::Store {
for loose_db in &*index.loose_dbs {
let out = loose_db
.verify_integrity(
progress.add_child_with_id(loose_db.path().display().to_string(), *b"VISP"), /* Verify Integrity Store Path */
progress.add_child_with_id(
loose_db.path().display().to_string(),
integrity::ProgressId::VerifyLooseObjectDbPath.into(),
),
should_interrupt,
)
.map(|statistics| integrity::LooseObjectStatistics {
Expand Down
19 changes: 18 additions & 1 deletion git-odb/src/store_impls/loose/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ pub mod integrity {
/// The amount of loose objects we checked.
pub num_objects: usize,
}

/// The progress ids used in [`verify_integrity()`][super::Store::verify_integrity()].
///
/// Use this information to selectively extract the progress of interest in case the parent application has custom visualization.
#[derive(Debug, Copy, Clone)]
pub enum ProgressId {
/// The amount of loose objects that have been verified.
LooseObjects,
}

impl From<ProgressId> for git_features::progress::Id {
fn from(v: ProgressId) -> Self {
match v {
ProgressId::LooseObjects => *b"VILO",
}
}
}
}

impl Store {
Expand All @@ -52,7 +69,7 @@ impl Store {

let mut num_objects = 0;
let start = Instant::now();
let mut progress = progress.add_child_with_id("Validating", *b"VILO"); /* Verify Integrity Loose Objects */
let mut progress = progress.add_child_with_id("Validating", integrity::ProgressId::LooseObjects.into());
progress.init(None, git_features::progress::count("loose objects"));
for id in self.iter().filter_map(Result::ok) {
let object = self
Expand Down
32 changes: 29 additions & 3 deletions git-pack/src/bundle/write/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::marker::PhantomData;
use std::{
io,
io::Write,
Expand All @@ -23,6 +24,28 @@ type ThinPackLookupFn = Box<dyn for<'a> FnMut(git_hash::ObjectId, &'a mut Vec<u8
type ThinPackLookupFnSend =
Box<dyn for<'a> FnMut(git_hash::ObjectId, &'a mut Vec<u8>) -> Option<git_object::Data<'a>> + Send + 'static>;

/// The progress ids used in [`write_to_directory()`][crate::Bundle::write_to_directory()].
///
/// Use this information to selectively extract the progress of interest in case the parent application has custom visualization.
#[derive(Debug, Copy, Clone)]
pub enum ProgressId {
/// The amount of bytes read from the input pack data file.
ReadPackBytes,
/// A root progress counting logical steps towards an index file on disk.
///
/// Underneath will be more progress information related to actually producing the index.
IndexingSteps(PhantomData<crate::index::write::ProgressId>),
}

impl From<ProgressId> for git_features::progress::Id {
fn from(v: ProgressId) -> Self {
match v {
ProgressId::ReadPackBytes => *b"BWRB",
ProgressId::IndexingSteps(_) => *b"BWCI",
}
}
}

impl crate::Bundle {
/// Given a `pack` data stream, write it along with a generated index into the `directory` if `Some` or discard all output if `None`.
///
Expand Down Expand Up @@ -50,7 +73,7 @@ impl crate::Bundle {
where
P: Progress,
{
let mut read_progress = progress.add_child_with_id("read pack", *b"BWRB"); /* Bundle Write Read pack Bytes*/
let mut read_progress = progress.add_child_with_id("read pack", ProgressId::ReadPackBytes.into());
read_progress.init(None, progress::bytes());
let pack = progress::Read {
inner: pack,
Expand Down Expand Up @@ -163,7 +186,7 @@ impl crate::Bundle {
P: Progress,
P::SubProgress: 'static,
{
let mut read_progress = progress.add_child_with_id("read pack", *b"BWRB"); /* Bundle Write Read pack Bytes*/
let mut read_progress = progress.add_child_with_id("read pack", ProgressId::ReadPackBytes.into()); /* Bundle Write Read pack Bytes*/
read_progress.init(pack_size.map(|s| s as usize), progress::bytes());
let pack = progress::Read {
inner: pack,
Expand Down Expand Up @@ -260,7 +283,10 @@ impl crate::Bundle {
should_interrupt: &AtomicBool,
pack_version: data::Version,
) -> Result<WriteOutcome, Error> {
let indexing_progress = progress.add_child_with_id("create index file", *b"BWCI"); /* Bundle Write Create Index */
let indexing_progress = progress.add_child_with_id(
"create index file",
ProgressId::IndexingSteps(Default::default()).into(),
);
Ok(match directory {
Some(directory) => {
let directory = directory.as_ref();
Expand Down
Loading

0 comments on commit 7bba270

Please sign in to comment.