History

Merge pull request #2000 from GitoxideLabs/improvements

various improvements

Sebastian Thiel committed 1 year ago

Commit fdfb2392 parents 33c4d6b f687cb12 files · +35 −3Browse files

Unified · Split

2 files
  1. gix/src/repository/mod.rs +14 −0
  2. gix/src/repository/revision.rs +21 −3
gix/src/repository/mod.rs+14−0
@@ -219,6 +219,20 @@ pub mod merge_base_octopus { · 218 unmodified lines
219219 }
220220 }
221221
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+
222236 ///
223237 #[cfg(feature = "merge")]
224238 pub mod tree_merge_options {
gix/src/repository/revision.rs+21−3
@@ -82,11 +82,11 @@ impl crate::Repository { · 81 unmodified lines
8282 Ok(bases[0].attach(self))
8383 }
8484
85− /// Obtain 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.
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 speed up the operation.
8787 ///
8888 /// # 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.
9090 #[doc(alias = "merge_bases_many", alias = "git2")]
9191 #[cfg(feature = "revision")]
9292 pub fn merge_bases_many_with_graph(
@@ -104,6 +104,24 @@ impl crate::Repository { · 11 unmodified lines
104104 .collect())
105105 }
106106
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+
107125 /// Return the best merge-base among all `commits`, or fail if `commits` yields no commit or no merge-base was found.
108126 ///
109127 /// Use `graph` to speed up repeated calls.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t