Skip to content

Commit 1f2ffb6

Browse files
committed
Merge branch 'optimize/progress-use'
2 parents e022096 + c80e809 commit 1f2ffb6

File tree

8 files changed

+40
-22
lines changed

8 files changed

+40
-22
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ gix = { version = "^0.53.1", path = "gix", default-features = false }
168168
time = "0.3.23"
169169

170170
clap = { version = "4.1.1", features = ["derive", "cargo"] }
171-
prodash = { version = "26.2.0", optional = true, default-features = false }
171+
prodash = { workspace = true, optional = true }
172172
is-terminal = { version = "0.4.0", optional = true }
173173
env_logger = { version = "0.10.0", default-features = false }
174174
crosstermion = { version = "0.11.0", optional = true, default-features = false }
@@ -292,6 +292,9 @@ members = [
292292
"gix-traverse/tests",
293293
]
294294

295+
[workspace.dependencies]
296+
prodash = { version = "26.2.2", default-features = false }
297+
295298
[package.metadata.docs.rs]
296299
features = ["document-features", "max"]
297300
rustdoc-args = ["--cfg", "docsrs"]

gix-features/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ crc32fast = { version = "1.2.1", optional = true }
129129
sha1 = { version = "0.10.0", optional = true }
130130

131131
# progress
132-
prodash = { version = "26.2.0", optional = true, default-features = false }
132+
prodash = { workspace = true, optional = true }
133133
bytesize = { version = "1.0.1", optional = true }
134134

135135
# pipe

gix-features/src/progress.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub use prodash::{
99
progress::{
1010
AtomicStep, Discard, DoOrDiscard, Either, Id, Step, StepShared, Task, ThroughputOnDrop, Value, UNKNOWN,
1111
},
12-
unit, Count, DynNestedProgress, NestedProgress, Progress, Unit,
12+
unit, BoxedDynNestedProgress, Count, DynNestedProgress, DynNestedProgressToNestedProgress, NestedProgress,
13+
Progress, Unit,
1314
};
1415
/// A stub for the portions of the `bytesize` crate that we use internally in `gitoxide`.
1516
#[cfg(not(feature = "progress-unit-bytes"))]

gix/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ gix-protocol = { version = "^0.39.0", path = "../gix-protocol", optional = true
243243
gix-transport = { version = "^0.36.0", path = "../gix-transport", optional = true }
244244

245245
# Just to get the progress-tree feature
246-
prodash = { version = "26.2", optional = true, default-features = false, features = ["progress-tree"] }
246+
prodash = { workspace = true, optional = true, features = ["progress-tree"] }
247247
once_cell = "1.14.0"
248248
signal-hook = { version = "0.3.9", default-features = false, optional = true }
249249
thiserror = "1.0.26"

gix/src/clone/fetch/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ impl PrepareFetch {
5858
P: crate::NestedProgress,
5959
P::SubProgress: 'static,
6060
{
61+
self.fetch_only_inner(&mut progress, should_interrupt).await
62+
}
63+
64+
#[gix_protocol::maybe_async::maybe_async]
65+
async fn fetch_only_inner(
66+
&mut self,
67+
progress: &mut dyn crate::DynNestedProgress,
68+
should_interrupt: &std::sync::atomic::AtomicBool,
69+
) -> Result<(crate::Repository, crate::remote::fetch::Outcome), Error> {
6170
use crate::{bstr::ByteVec, remote, remote::fetch::RefLogMessage};
6271

6372
let repo = self
@@ -111,7 +120,7 @@ impl PrepareFetch {
111120
f(&mut connection).map_err(|err| Error::RemoteConnection(err))?;
112121
}
113122
connection
114-
.prepare_fetch(&mut progress, {
123+
.prepare_fetch(&mut *progress, {
115124
let mut opts = self.fetch_options.clone();
116125
if !opts.extra_refspecs.contains(&head_refspec) {
117126
opts.extra_refspecs.push(head_refspec)
@@ -134,7 +143,7 @@ impl PrepareFetch {
134143
message: reflog_message.clone(),
135144
})
136145
.with_shallow(self.shallow.clone())
137-
.receive(progress, should_interrupt)
146+
.receive_inner(progress, should_interrupt)
138147
.await?;
139148

140149
util::append_config_to_repo_config(repo, config);

gix/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub use gix_features as features;
9898
use gix_features::threading::OwnShared;
9999
pub use gix_features::{
100100
parallel,
101-
progress::{Count, NestedProgress, Progress},
101+
progress::{Count, DynNestedProgress, NestedProgress, Progress},
102102
threading,
103103
};
104104
pub use gix_fs as fs;

gix/src/remote/connection/fetch/receive_pack.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,28 @@ where
7373
/// - `gitoxide.userAgent` is read to obtain the application user agent for git servers and for HTTP servers as well.
7474
///
7575
#[gix_protocol::maybe_async::maybe_async]
76-
#[allow(clippy::drop_non_drop)]
77-
pub async fn receive<P>(mut self, mut progress: P, should_interrupt: &AtomicBool) -> Result<Outcome, Error>
76+
pub async fn receive<P>(self, mut progress: P, should_interrupt: &AtomicBool) -> Result<Outcome, Error>
7877
where
7978
P: gix_features::progress::NestedProgress,
8079
P::SubProgress: 'static,
8180
{
81+
self.receive_inner(&mut progress, should_interrupt).await
82+
}
83+
84+
#[gix_protocol::maybe_async::maybe_async]
85+
#[allow(clippy::drop_non_drop)]
86+
pub(crate) async fn receive_inner(
87+
mut self,
88+
progress: &mut dyn crate::DynNestedProgress,
89+
should_interrupt: &AtomicBool,
90+
) -> Result<Outcome, Error> {
8291
let _span = gix_trace::coarse!("fetch::Prepare::receive()");
8392
let mut con = self.con.take().expect("receive() can only be called once");
8493

8594
let handshake = &self.ref_map.handshake;
8695
let protocol_version = handshake.server_protocol_version;
8796

8897
let fetch = gix_protocol::Command::Fetch;
89-
let progress = &mut progress;
9098
let repo = con.remote.repo;
9199
let fetch_features = {
92100
let mut f = fetch.default_features(protocol_version, &handshake.capabilities);
@@ -379,17 +387,14 @@ fn add_shallow_args(
379387
Ok((shallow_commits, shallow_lock))
380388
}
381389

382-
fn setup_remote_progress<P>(
383-
progress: &mut P,
390+
fn setup_remote_progress(
391+
progress: &mut dyn crate::DynNestedProgress,
384392
reader: &mut Box<dyn gix_protocol::transport::client::ExtendedBufRead + Unpin + '_>,
385393
should_interrupt: &AtomicBool,
386-
) where
387-
P: gix_features::progress::NestedProgress,
388-
P::SubProgress: 'static,
389-
{
394+
) {
390395
use gix_protocol::transport::client::ExtendedBufRead;
391396
reader.set_progress_handler(Some(Box::new({
392-
let mut remote_progress = progress.add_child_with_id("remote", ProgressId::RemoteProgress.into());
397+
let mut remote_progress = progress.add_child_with_id("remote".to_string(), ProgressId::RemoteProgress.into());
393398
// SAFETY: Ugh, so, with current Rust I can't declare lifetimes in the involved traits the way they need to
394399
// be and I also can't use scoped threads to pump from local scopes to an Arc version that could be
395400
// used here due to the this being called from sync AND async code (and the async version doesn't work

0 commit comments

Comments
 (0)