From cde8ea8985ee90be9e0907f3875f26934f8f6a95 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 17 Dec 2023 17:44:32 -0800 Subject: [PATCH] Make CommitBuilder constructors private to the library crate The implementation of `CommitBuilder::write` is tightly bound to the MutRepo, so only MutRepo should construct CommitBuilder-s. --- lib/src/commit_builder.rs | 6 ++++-- lib/src/repo.rs | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/commit_builder.rs b/lib/src/commit_builder.rs index 67c50e48a..7a6ea1d2b 100644 --- a/lib/src/commit_builder.rs +++ b/lib/src/commit_builder.rs @@ -32,7 +32,8 @@ pub struct CommitBuilder<'repo> { } impl CommitBuilder<'_> { - pub fn for_new_commit<'repo>( + // Use MutRepo::new_commit() instead + pub(crate) fn for_new_commit<'repo>( mut_repo: &'repo mut MutableRepo, settings: &UserSettings, parents: Vec, @@ -61,7 +62,8 @@ impl CommitBuilder<'_> { } } - pub fn for_rewrite_from<'repo>( + // Use MutRepo::rewrite_commit() instead + pub(crate) fn for_rewrite_from<'repo>( mut_repo: &'repo mut MutableRepo, settings: &UserSettings, predecessor: &Commit, diff --git a/lib/src/repo.rs b/lib/src/repo.rs index dbc3f5193..bfe88867d 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -796,6 +796,8 @@ impl MutableRepo { predecessor: &Commit, ) -> CommitBuilder { CommitBuilder::for_rewrite_from(self, settings, predecessor) + // CommitBuilder::write will record the rewrite in + // `self.rewritten_commits` } pub fn write_commit(