various improvements
Unified · Split
| @@ -219,6 +219,20 @@ pub mod merge_base_octopus { · 218 unmodified lines | |||
| 219 | } | 219 | } |
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | /// | ||
| 223 | #[cfg(feature = "revision")] | ||
| 224 | pub mod merge_bases_many { | ||
| 225 | /// The error returned by [Repository::merge_bases_many()](crate::Repository::merge_bases_many()). | ||
| 226 | #[derive(Debug, thiserror::Error)] | ||
| 227 | #[allow(missing_docs)] | ||
| 228 | pub enum Error { | ||
| 229 | #[error(transparent)] | ||
| 230 | OpenCache(#[from] crate::repository::commit_graph_if_enabled::Error), | ||
| 231 | #[error(transparent)] | ||
| 232 | MergeBase(#[from] gix_revision::merge_base::Error), | ||
| 233 | } | ||
| 234 | } | ||
| 235 | |||
| 222 | /// | 236 | /// |
| 223 | #[cfg(feature = "merge")] | 237 | #[cfg(feature = "merge")] |
| 224 | pub mod tree_merge_options { | 238 | pub mod tree_merge_options { |
| @@ -82,11 +82,11 @@ impl crate::Repository { · 81 unmodified lines | |||
| 82 | Ok(bases[0].attach(self)) | 82 | Ok(bases[0].attach(self)) |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | /// Obtain all merge-bases between commit `one` and `others`, or an empty list if there is none, providing a | 85 | /// Get all merge-bases between commit `one` and `others`, or an empty list if there is none, providing a |
| 86 | /// commit-graph `graph` to potentially greatly accelerate the operation. | 86 | /// commit-graph `graph` to potentially greatly speed up the operation. |
| 87 | /// | 87 | /// |
| 88 | /// # Performance | 88 | /// # Performance |
| 89 | /// Be sure to [set an object cache](crate::Repository::object_cache_size_if_unset) to accelerate repeated commit lookups. | 89 | /// Be sure to [set an object cache](crate::Repository::object_cache_size_if_unset) to speed up repeated commit lookups. |
| 90 | #[doc(alias = "merge_bases_many", alias = "git2")] | 90 | #[doc(alias = "merge_bases_many", alias = "git2")] |
| 91 | #[cfg(feature = "revision")] | 91 | #[cfg(feature = "revision")] |
| 92 | pub fn merge_bases_many_with_graph( | 92 | pub fn merge_bases_many_with_graph( |
| @@ -104,6 +104,24 @@ impl crate::Repository { · 11 unmodified lines | |||
| 104 | .collect()) | 104 | .collect()) |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | /// Like [`merge_bases_many_with_graph()`](Self::merge_bases_many_with_graph), but without the ability to speed up consecutive calls with a [graph](gix_revwalk::Graph). | ||
| 108 | /// | ||
| 109 | /// # Performance | ||
| 110 | /// | ||
| 111 | /// Be sure to [set an object cache](crate::Repository::object_cache_size_if_unset) to speed up repeated commit lookups, and consider | ||
| 112 | /// using [`merge_bases_many_with_graph()`](Self::merge_bases_many_with_graph) for consecutive calls. | ||
| 113 | #[doc(alias = "git2")] | ||
| 114 | #[cfg(feature = "revision")] | ||
| 115 | pub fn merge_bases_many( | ||
| 116 | &self, | ||
| 117 | one: impl Into<gix_hash::ObjectId>, | ||
| 118 | others: &[gix_hash::ObjectId], | ||
| 119 | ) -> Result<Vec<Id<'_>>, crate::repository::merge_bases_many::Error> { | ||
| 120 | let cache = self.commit_graph_if_enabled()?; | ||
| 121 | let mut graph = self.revision_graph(cache.as_ref()); | ||
| 122 | Ok(self.merge_bases_many_with_graph(one, others, &mut graph)?) | ||
| 123 | } | ||
| 124 | |||
| 107 | /// Return the best merge-base among all `commits`, or fail if `commits` yields no commit or no merge-base was found. | 125 | /// Return the best merge-base among all `commits`, or fail if `commits` yields no commit or no merge-base was found. |
| 108 | /// | 126 | /// |
| 109 | /// Use `graph` to speed up repeated calls. | 127 | /// Use `graph` to speed up repeated calls. |