Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust visibility of codependent MutableRepo and CommitBuilder functions #3193

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/src/commit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct CommitBuilder<'repo> {
}

impl CommitBuilder<'_> {
// Use MutRepo::new_commit() instead
/// Only called from [`MutRepo::new_commit`]. Use that function instead.
pub(crate) fn for_new_commit<'repo>(
mut_repo: &'repo mut MutableRepo,
settings: &UserSettings,
Expand Down Expand Up @@ -62,7 +62,7 @@ impl CommitBuilder<'_> {
}
}

// Use MutRepo::rewrite_commit() instead
/// Only called from [`MutRepo::rewrite_commit`]. Use that function instead.
pub(crate) fn for_rewrite_from<'repo>(
mut_repo: &'repo mut MutableRepo,
settings: &UserSettings,
Expand Down
7 changes: 5 additions & 2 deletions lib/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,11 +771,12 @@ impl MutableRepo {
&& self.view() == &self.base_repo.view)
}

pub fn consume(self) -> (Box<dyn MutableIndex>, View) {
pub(crate) fn consume(self) -> (Box<dyn MutableIndex>, View) {
self.view.ensure_clean(|v| self.enforce_view_invariants(v));
(self.index, self.view.into_inner())
}

/// Returns a [`CommitBuilder`] to write new commit to the repo.
pub fn new_commit(
&mut self,
settings: &UserSettings,
Expand All @@ -785,6 +786,7 @@ impl MutableRepo {
CommitBuilder::for_new_commit(self, settings, parents, tree_id)
}

/// Returns a [`CommitBuilder`] to rewrite an existing commit in the repo.
pub fn rewrite_commit(
&mut self,
settings: &UserSettings,
Expand All @@ -795,7 +797,8 @@ impl MutableRepo {
// `self.rewritten_commits`
}

pub fn write_commit(
/// Only called from [`CommitBuilder::write`]. Use that function instead.
pub(crate) fn write_commit(
&mut self,
commit: backend::Commit,
sign_with: Option<&mut SigningFn>,
Expand Down