Skip to content

Commit 90c6c5a

Browse files
committed
Upgrade to prodash 19
1 parent 8ab19a6 commit 90c6c5a

File tree

5 files changed

+20
-27
lines changed

5 files changed

+20
-27
lines changed

Diff for: Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ lean-async = ["fast", "pretty-cli", "gitoxide-core-tools", "gitoxide-core-async-
5757

5858
## As small as it can possibly be, no threading, no fast sha1, log based progress only, rust based zlib implementation.
5959
## no networking, local operations only.
60-
small = ["pretty-cli", "git-features/rustsha1", "git-features/zlib-rust-backend", "prodash/progress-log", "atty"]
60+
small = ["pretty-cli", "git-features/rustsha1", "git-features/zlib-rust-backend", "prodash/progress-log", "atty", "env_logger"]
6161

6262
#! ### `gitoxide-core` Configuration
6363

@@ -89,7 +89,7 @@ git-repository = { version = "^0.15.0", path = "git-repository", default-feature
8989
git-transport-for-configuration-only = { package = "git-transport", optional = true, version = "^0.15.0", path = "git-transport" }
9090

9191
clap = { version = "3.0.0", features = ["derive", "cargo"] }
92-
prodash = { version = "18.0.0", optional = true, default-features = false }
92+
prodash = { version = "19.0.0", optional = true, default-features = false }
9393
atty = { version = "0.2.14", optional = true, default-features = false }
9494
env_logger = { version = "0.9.0", optional = true, default-features = false, features = ["humantime", "termcolor", "atty"] }
9595
crosstermion = { version = "0.9.0", optional = true, default-features = false }

Diff for: git-features/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ crc32fast = { version = "1.2.1", optional = true }
110110
sha-1 = { version = "0.10.0", optional = true }
111111

112112
# progress
113-
prodash = { version = "18.0.0", optional = true, default-features = false, features = ["unit-bytes", "unit-human"] }
113+
prodash = { version = "19.0.0", optional = true, default-features = false, features = ["unit-bytes", "unit-human"] }
114114

115115
# pipe
116116
bytes = { version = "1.0.0", optional = true }

Diff for: src/plumbing/main.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ pub mod async_util {
3333
range: impl Into<Option<ProgressRange>>,
3434
) -> (Option<prodash::render::line::JoinHandle>, Option<prodash::tree::Item>) {
3535
use crate::shared::{self, STANDARD_RANGE};
36-
crate::shared::init_env_logger(false);
36+
crate::shared::init_env_logger();
3737

3838
if verbose {
3939
let progress = crate::shared::progress_tree();
4040
let sub_progress = progress.add_child(name);
41-
let ui_handle = shared::setup_line_renderer_range(progress, range.into().unwrap_or(STANDARD_RANGE));
41+
let ui_handle = shared::setup_line_renderer_range(&progress, range.into().unwrap_or(STANDARD_RANGE));
4242
(Some(ui_handle), Some(sub_progress))
4343
} else {
4444
(None, None)
@@ -425,11 +425,7 @@ pub fn main() -> Result<()> {
425425
progress_keep_open,
426426
core::pack::multi_index::PROGRESS_RANGE,
427427
move |progress, _out, _err| {
428-
core::pack::multi_index::verify(
429-
multi_index_path,
430-
progress,
431-
&git_repository::interrupt::IS_INTERRUPTED,
432-
)
428+
core::pack::multi_index::verify(multi_index_path, progress, &should_interrupt)
433429
},
434430
),
435431
pack::multi_index::Subcommands::Create { index_paths } => prepare_and_run(
@@ -443,7 +439,7 @@ pub fn main() -> Result<()> {
443439
index_paths,
444440
multi_index_path,
445441
progress,
446-
&git_repository::interrupt::IS_INTERRUPTED,
442+
&should_interrupt,
447443
object_hash,
448444
)
449445
},

Diff for: src/shared.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ pub const STANDARD_RANGE: ProgressRange = 2..=2;
1010
/// will just be initialized.
1111
#[cfg(feature = "env_logger")]
1212
#[allow(unused)] // Squelch warning because it's used in porcelain as well and we can't know that at compile time
13-
pub fn init_env_logger(verbose: bool) {
14-
if verbose {
13+
pub fn init_env_logger() {
14+
if cfg!(feature = "small") {
1515
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
1616
.format_module_path(false)
1717
.init();
@@ -21,7 +21,7 @@ pub fn init_env_logger(verbose: bool) {
2121
}
2222

2323
#[cfg(feature = "prodash-render-line")]
24-
pub fn progress_tree() -> prodash::Tree {
24+
pub fn progress_tree() -> std::sync::Arc<prodash::Tree> {
2525
prodash::TreeOptions {
2626
message_buffer_capacity: 200,
2727
..Default::default()
@@ -74,7 +74,7 @@ pub mod pretty {
7474
+ std::panic::UnwindSafe
7575
+ 'static,
7676
) -> Result<T> {
77-
crate::shared::init_env_logger(false);
77+
crate::shared::init_env_logger();
7878

7979
match (verbose, progress) {
8080
(false, false) => {
@@ -91,12 +91,10 @@ pub mod pretty {
9191
{
9292
let stdout = stdout();
9393
let mut stdout_lock = stdout.lock();
94-
let stderr = stderr();
95-
let mut stderr_lock = stderr.lock();
9694
run(
9795
progress::DoOrDiscard::from(Some(sub_progress)),
9896
&mut stdout_lock,
99-
&mut stderr_lock,
97+
&mut stderr(),
10098
)
10199
}
102100
#[cfg(feature = "prodash-render-line")]
@@ -108,7 +106,8 @@ pub mod pretty {
108106
}
109107
use crate::shared::{self, STANDARD_RANGE};
110108
let (tx, rx) = std::sync::mpsc::sync_channel::<Event<T>>(1);
111-
let ui_handle = shared::setup_line_renderer_range(progress, range.into().unwrap_or(STANDARD_RANGE));
109+
let ui_handle =
110+
shared::setup_line_renderer_range(&progress, range.into().unwrap_or(STANDARD_RANGE));
112111
std::thread::spawn({
113112
let tx = tx.clone();
114113
move || loop {
@@ -119,8 +118,6 @@ pub mod pretty {
119118
}
120119
}
121120
});
122-
// LIMITATION: This will hang if the thread panics as no message is send and the renderer thread will wait forever.
123-
// `catch_unwind` can't be used as a parking lot mutex is not unwind safe, coming from prodash.
124121
let join_handle = std::thread::spawn(move || {
125122
let mut out = Vec::<u8>::new();
126123
let res = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
@@ -171,11 +168,11 @@ pub mod pretty {
171168
let sub_progress = progress.add_child(name);
172169
let render_tui = prodash::render::tui(
173170
stdout(),
174-
progress,
171+
std::sync::Arc::downgrade(&progress),
175172
prodash::render::tui::Options {
176173
title: "gitoxide".into(),
177174
frames_per_second: shared::DEFAULT_FRAME_RATE,
178-
stop_if_empty_progress: !progress_keep_open,
175+
stop_if_progress_missing: !progress_keep_open,
179176
throughput: true,
180177
..Default::default()
181178
},
@@ -219,12 +216,12 @@ pub mod pretty {
219216
#[allow(unused)]
220217
#[cfg(feature = "prodash-render-line")]
221218
pub fn setup_line_renderer_range(
222-
progress: prodash::Tree,
219+
progress: &std::sync::Arc<prodash::Tree>,
223220
levels: std::ops::RangeInclusive<prodash::progress::key::Level>,
224221
) -> prodash::render::line::JoinHandle {
225222
prodash::render::line(
226223
std::io::stderr(),
227-
progress,
224+
std::sync::Arc::downgrade(progress),
228225
prodash::render::line::Options {
229226
level_filter: Some(levels),
230227
frames_per_second: DEFAULT_FRAME_RATE,

0 commit comments

Comments
 (0)