diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:57:19 +0000 |
commit | a0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch) | |
tree | fc451898ccaf445814e26b46664d78702178101d /vendor/gix-lock | |
parent | Adding debian version 1.71.1+dfsg1-2. (diff) | |
download | rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip |
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-lock')
-rw-r--r-- | vendor/gix-lock/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/gix-lock/CHANGELOG.md | 63 | ||||
-rw-r--r-- | vendor/gix-lock/Cargo.toml | 11 | ||||
-rw-r--r-- | vendor/gix-lock/src/acquire.rs | 9 | ||||
-rw-r--r-- | vendor/gix-lock/src/backoff.rs | 142 | ||||
-rw-r--r-- | vendor/gix-lock/src/file.rs | 2 | ||||
-rw-r--r-- | vendor/gix-lock/src/lib.rs | 4 |
7 files changed, 74 insertions, 159 deletions
diff --git a/vendor/gix-lock/.cargo-checksum.json b/vendor/gix-lock/.cargo-checksum.json index 7ed9f18a3..09cd88c30 100644 --- a/vendor/gix-lock/.cargo-checksum.json +++ b/vendor/gix-lock/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"556fada43e17ddd0abdc0188ee93cbe535443d0fbf4ff3fc3ba8fe40698f6e44","Cargo.toml":"e20b3d82248d4fb3999a1125cf24e38e76ec36c93523bed3df33b3d714663ea0","LICENSE-APACHE":"cb4780590812826851ba250f90bed0ed19506ec98f6865a0e2e20bbf62391ff9","LICENSE-MIT":"49df47913ab2beafe8dc45607877ae64198bf0eee64aaad3e82ed9e4d27424e8","README.md":"cf2fb5b63a81699b01aaa03994874d70af2d8650a047b41350924c8f900c7ea9","src/acquire.rs":"405fa3dce6b9e7035e0966a906da932623ccc323f33ea36f4e7365a9e3c5e5ac","src/backoff.rs":"d8bc6672b6ceb2c70ac335c453904cb102c0a74c25605bd01b5ce4bd5f0e9571","src/commit.rs":"5dd467479f5eed435c7ddc4b5b4b9d89acd88521ce8d747efda92a3ce881df46","src/file.rs":"19c050dcbd5b4f892570fbc0303c254e52bc650fa2559d6a5b16e1f44388c679","src/lib.rs":"528fe39f621458d2b7a0f7c9be042f22f71083c9e031c60faa9ad549e183ecad"},"package":"41b80172055c5d8017a48ddac5cc7a95421c00211047db0165c97853c4f05194"}
\ No newline at end of file +{"files":{"CHANGELOG.md":"da8a00cd96b83c482a11d612a330acbb81e3e0f762212cfabdaa01aec091ac26","Cargo.toml":"22d838b21939bc6f4ff3e1017c4a0d0421c1e55adef553a9cdef3a573ae46e9c","LICENSE-APACHE":"cb4780590812826851ba250f90bed0ed19506ec98f6865a0e2e20bbf62391ff9","LICENSE-MIT":"49df47913ab2beafe8dc45607877ae64198bf0eee64aaad3e82ed9e4d27424e8","README.md":"cf2fb5b63a81699b01aaa03994874d70af2d8650a047b41350924c8f900c7ea9","src/acquire.rs":"3cdcbe8becc0fdb54e981907f20d1e24ff8125b0b2f3b7c47f6d6ffcfb49b5f9","src/commit.rs":"5dd467479f5eed435c7ddc4b5b4b9d89acd88521ce8d747efda92a3ce881df46","src/file.rs":"70206a11fd815d8e4ea4bedcd63cebe5df51695ceaf54bc93db5dc2032074fc2","src/lib.rs":"20707f4e68faf8baf40509e601a99173e7c2a04199c86b7beebc24c2a346e345"},"package":"3ec5d5e6f07316d3553aa7425e3ecd935ec29882556021fe1696297a448af8d2"}
\ No newline at end of file diff --git a/vendor/gix-lock/CHANGELOG.md b/vendor/gix-lock/CHANGELOG.md index e2891a16d..a5c9a0d96 100644 --- a/vendor/gix-lock/CHANGELOG.md +++ b/vendor/gix-lock/CHANGELOG.md @@ -5,6 +5,66 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 6.0.0 (2023-06-06) + +A maintenance release without user-facing changes. + +### Commit Statistics + +<csr-read-only-do-not-edit/> + + - 3 commits contributed to the release over the course of 11 calendar days. + - 40 days passed between releases. + - 0 commits were understood as [conventional](https://www.conventionalcommits.org). + - 0 issues like '(#ID)' were seen in commit messages + +### Commit Details + +<csr-read-only-do-not-edit/> + +<details><summary>view details</summary> + + * **Uncategorized** + - Prepare changelogs prior to release ([`8f15cec`](https://github.com/Byron/gitoxide/commit/8f15cec1ec7d5a9d56bb158f155011ef2bb3539b)) + - Merge branch 'fix-docs' ([`420553a`](https://github.com/Byron/gitoxide/commit/420553a10d780e0b2dc466cac120989298a5f187)) + - Cleaning up documentation ([`2578e57`](https://github.com/Byron/gitoxide/commit/2578e576bfa365d194a23a1fb0bf09be230873de)) +</details> + +## 5.0.1 (2023-04-26) + +A maintenance release without user-facing changes. + +### Commit Statistics + +<csr-read-only-do-not-edit/> + + - 7 commits contributed to the release over the course of 46 calendar days. + - 46 days passed between releases. + - 0 commits were understood as [conventional](https://www.conventionalcommits.org). + - 0 issues like '(#ID)' were seen in commit messages + +### Thanks Clippy + +<csr-read-only-do-not-edit/> + +[Clippy](https://github.com/rust-lang/rust-clippy) helped 1 time to make code idiomatic. + +### Commit Details + +<csr-read-only-do-not-edit/> + +<details><summary>view details</summary> + + * **Uncategorized** + - Release gix-hash v0.11.1, gix-path v0.7.4, gix-glob v0.6.0, gix-attributes v0.11.0, gix-config-value v0.11.0, gix-fs v0.1.1, gix-tempfile v5.0.3, gix-utils v0.1.1, gix-lock v5.0.1, gix-object v0.29.1, gix-ref v0.28.0, gix-sec v0.7.0, gix-config v0.21.0, gix-prompt v0.4.0, gix-url v0.17.0, gix-credentials v0.13.0, gix-diff v0.29.0, gix-discover v0.17.0, gix-hashtable v0.2.0, gix-ignore v0.1.0, gix-bitmap v0.2.3, gix-traverse v0.25.0, gix-index v0.16.0, gix-mailmap v0.12.0, gix-pack v0.34.0, gix-odb v0.44.0, gix-packetline v0.16.0, gix-transport v0.30.0, gix-protocol v0.31.0, gix-revision v0.13.0, gix-refspec v0.10.0, gix-worktree v0.16.0, gix v0.44.0, safety bump 7 crates ([`91134a1`](https://github.com/Byron/gitoxide/commit/91134a11c8ba0e942f692488ec9bce9fa1086324)) + - Prepare changelogs prior to release ([`30a1a71`](https://github.com/Byron/gitoxide/commit/30a1a71f36f24faac0e0b362ffdfedea7f9cdbf1)) + - Merge branch 'fix-823' ([`6ebd61e`](https://github.com/Byron/gitoxide/commit/6ebd61e548a36a04e413ac725a03e607a3588334)) + - Thanks clippy ([`14e64e7`](https://github.com/Byron/gitoxide/commit/14e64e74649cfb1f2f99da87015939af98fae5c8)) + - Release gix-utils v0.1.0, gix-hash v0.11.0, gix-date v0.5.0, gix-features v0.29.0, gix-actor v0.20.0, gix-object v0.29.0, gix-archive v0.1.0, gix-fs v0.1.0, safety bump 25 crates ([`8dbd0a6`](https://github.com/Byron/gitoxide/commit/8dbd0a60557a85acfa231800a058cbac0271a8cf)) + - Create new `gix-fs` crate to consolidate all filesystem utilities ([`f8cc33c`](https://github.com/Byron/gitoxide/commit/f8cc33cb372dd2b4bbe4a09cf4f64916681ab1dd)) + - Merge branch 'fix-cred-helper' ([`01277a6`](https://github.com/Byron/gitoxide/commit/01277a681e4997896e04567490c572b5af606f35)) +</details> + ## 5.0.0 (2023-03-10) A maintenance release without user-facing changes. @@ -13,7 +73,7 @@ A maintenance release without user-facing changes. <csr-read-only-do-not-edit/> - - 1 commit contributed to the release. + - 2 commits contributed to the release. - 9 days passed between releases. - 0 commits were understood as [conventional](https://www.conventionalcommits.org). - 0 issues like '(#ID)' were seen in commit messages @@ -25,6 +85,7 @@ A maintenance release without user-facing changes. <details><summary>view details</summary> * **Uncategorized** + - Release gix-tempfile v5.0.0, gix-lock v5.0.0, gix-ref v0.27.0, gix-config v0.19.0, gix-url v0.16.0, gix-credentials v0.12.0, gix-discover v0.16.0, gix-index v0.15.0, gix-pack v0.33.0, gix-odb v0.43.0, gix-transport v0.28.0, gix-protocol v0.29.0, gix-worktree v0.15.0, gix v0.41.0, safety bump 12 crates ([`29a0870`](https://github.com/Byron/gitoxide/commit/29a087043d1feb2f127b065341c8028d0bd0301e)) - Prepare changelogs prior to release ([`e06f5f5`](https://github.com/Byron/gitoxide/commit/e06f5f523e83f4da390eddbebcb9a2d58674587b)) </details> diff --git a/vendor/gix-lock/Cargo.toml b/vendor/gix-lock/Cargo.toml index 4ff0a23b5..5884c4710 100644 --- a/vendor/gix-lock/Cargo.toml +++ b/vendor/gix-lock/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" rust-version = "1.64" name = "gix-lock" -version = "5.0.0" +version = "6.0.0" authors = ["Sebastian Thiel <sebastian.thiel@icloud.com>"] include = [ "src/**/*", @@ -30,11 +30,12 @@ repository = "https://github.com/Byron/gitoxide" test = true doctest = false -[dependencies.fastrand] -version = "1.5.0" - [dependencies.gix-tempfile] -version = "^5.0.0" +version = "^6.0.0" +default-features = false + +[dependencies.gix-utils] +version = "^0.1.2" default-features = false [dependencies.thiserror] diff --git a/vendor/gix-lock/src/acquire.rs b/vendor/gix-lock/src/acquire.rs index 93655a7da..c94fd110a 100644 --- a/vendor/gix-lock/src/acquire.rs +++ b/vendor/gix-lock/src/acquire.rs @@ -9,21 +9,16 @@ use gix_tempfile::{AutoRemove, ContainingDirectory}; use crate::{backoff, File, Marker, DOT_LOCK_SUFFIX}; /// Describe what to do if a lock cannot be obtained as it's already held elsewhere. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] +#[derive(Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub enum Fail { /// Fail after the first unsuccessful attempt of obtaining a lock. + #[default] Immediately, /// Retry after failure with exponentially longer sleep times to block the current thread. /// Fail once the given duration is exceeded, similar to [Fail::Immediately] AfterDurationWithBackoff(Duration), } -impl Default for Fail { - fn default() -> Self { - Fail::Immediately - } -} - impl fmt::Display for Fail { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { diff --git a/vendor/gix-lock/src/backoff.rs b/vendor/gix-lock/src/backoff.rs deleted file mode 100644 index f1c3559a6..000000000 --- a/vendor/gix-lock/src/backoff.rs +++ /dev/null @@ -1,142 +0,0 @@ -use std::time::Duration; - -fn randomize(backoff_ms: usize) -> usize { - let new_value = (fastrand::usize(750..=1250) * backoff_ms) / 1000; - if new_value == 0 { - backoff_ms - } else { - new_value - } -} - -/// A utility to calculate steps for exponential backoff similar to how it's done in `git`. -pub struct Exponential<Fn> { - multiplier: usize, - max_multiplier: usize, - exponent: usize, - transform: Fn, -} - -impl Default for Exponential<fn(usize) -> usize> { - fn default() -> Self { - Exponential { - multiplier: 1, - max_multiplier: 1000, - exponent: 1, - transform: std::convert::identity, - } - } -} - -impl Exponential<fn(usize) -> usize> { - /// Create a new exponential backoff iterator that backs off in randomized, ever increasing steps. - pub fn default_with_random() -> Self { - Exponential { - multiplier: 1, - max_multiplier: 1000, - exponent: 1, - transform: randomize, - } - } -} - -impl<Transform> Exponential<Transform> -where - Transform: Fn(usize) -> usize, -{ - /// Return an iterator that yields `Duration` instances to sleep on until `time` is depleted. - pub fn until_no_remaining(&mut self, time: Duration) -> impl Iterator<Item = Duration> + '_ { - let mut elapsed = Duration::default(); - let mut stop_next_iteration = false; - self.take_while(move |d| { - if stop_next_iteration { - false - } else { - elapsed += *d; - if elapsed > time { - stop_next_iteration = true; - } - true - } - }) - } -} - -impl<Transform> Iterator for Exponential<Transform> -where - Transform: Fn(usize) -> usize, -{ - type Item = Duration; - - fn next(&mut self) -> Option<Self::Item> { - let wait = Duration::from_millis((self.transform)(self.multiplier) as u64); - - self.multiplier += 2 * self.exponent + 1; - if self.multiplier > self.max_multiplier { - self.multiplier = self.max_multiplier; - } else { - self.exponent += 1; - } - Some(wait) - } -} - -#[cfg(test)] -mod tests { - use std::convert::TryInto; - - use super::*; - - const EXPECTED_TILL_SECOND: &[usize] = &[ - 1usize, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, - 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1000, - ]; - - #[test] - fn random_exponential_produces_values_in_the_correct_range() { - let mut num_identities = 0; - for (actual, expected) in Exponential::default_with_random().zip(EXPECTED_TILL_SECOND) { - let actual: usize = actual.as_millis().try_into().unwrap(); - if actual == *expected { - num_identities += 1; - } - assert!( - actual * 1000 >= (expected - 1) * 750, - "value too small: {actual} < {expected}" - ); - assert!( - actual * 1000 <= (expected + 1) * 1250, - "value too big: {actual} > {expected}" - ); - } - assert!( - num_identities < EXPECTED_TILL_SECOND.len(), - "too many untransformed values: {num_identities}" - ); - } - - #[test] - fn how_many_iterations_for_a_second_of_waittime() { - let max = Duration::from_millis(1000); - assert_eq!(Exponential::default().until_no_remaining(max).count(), 14); - assert_eq!( - Exponential::default() - .until_no_remaining(max) - .reduce(|acc, n| acc + n) - .unwrap(), - Duration::from_millis(1015), - "a little overshoot" - ); - } - - #[test] - fn output_with_default_settings() { - assert_eq!( - Exponential::default().take(33).collect::<Vec<_>>(), - EXPECTED_TILL_SECOND - .iter() - .map(|n| Duration::from_millis(*n as u64)) - .collect::<Vec<_>>() - ); - } -} diff --git a/vendor/gix-lock/src/file.rs b/vendor/gix-lock/src/file.rs index ad9a6db06..24ec98f13 100644 --- a/vendor/gix-lock/src/file.rs +++ b/vendor/gix-lock/src/file.rs @@ -17,7 +17,7 @@ impl File { self.inner.with_mut(|tf| f(tf.as_file_mut())).and_then(|res| res) } /// Close the lock file to prevent further writes and to save system resources. - /// A call to [Marker::commit()] is allowed on the [`Marker`] to write changes back to the resource. + /// A call to [`Marker::commit()`] is allowed on the [`Marker`] to write changes back to the resource. pub fn close(self) -> std::io::Result<Marker> { Ok(Marker { inner: self.inner.close()?, diff --git a/vendor/gix-lock/src/lib.rs b/vendor/gix-lock/src/lib.rs index 882e15492..3f131f7a6 100644 --- a/vendor/gix-lock/src/lib.rs +++ b/vendor/gix-lock/src/lib.rs @@ -24,8 +24,8 @@ const DOT_LOCK_SUFFIX: &str = ".lock"; /// pub mod acquire; -/// -pub mod backoff; + +pub use gix_utils::backoff; /// pub mod commit; |