Skip to content

Commit cbd5550

Browse files
gustavoavenafacebook-github-bot
authored andcommitted
Clean up commit_transformation create exports
Summary: # This stack ## **Please see D70781050 before reviewing this to get context on the plan and the goal.** ## This diff TODO Differential Revision: D71966346 fbshipit-source-id: 97adf1e0242b76a9ce766ab7081b9db17ae2b582
1 parent 8d761ad commit cbd5550

File tree

3 files changed

+21
-85
lines changed

3 files changed

+21
-85
lines changed

eden/mononoke/megarepo_api/commit_transformation/src/commit_rewriting.rs

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use anyhow::Error;
1515
use anyhow::Result;
1616
use blobrepo_utils::convert_diff_result_into_file_change_for_diamond_merge;
1717
use blobsync::copy_content;
18-
use borrowed::borrowed;
1918
use changesets_creation::save_changesets;
2019
use commit_graph::CommitGraphRef;
2120
use commit_graph::CommitGraphWriterRef;
@@ -245,86 +244,7 @@ pub async fn rewrite_as_squashed_commit<'a>(
245244
Ok(Some(cs))
246245
}
247246

248-
pub async fn rewrite_stack_no_merges<'a>(
249-
ctx: &'a CoreContext,
250-
css: Vec<BonsaiChangeset>,
251-
mut rewritten_parent: ChangesetId,
252-
mover: Arc<dyn MultiMover + 'a>,
253-
source_repo: &'a impl Repo,
254-
force_first_parent: Option<ChangesetId>,
255-
mut modify_bonsai_cs: impl FnMut((ChangesetId, BonsaiChangesetMut)) -> BonsaiChangesetMut,
256-
) -> Result<Vec<Option<BonsaiChangeset>>, Error> {
257-
borrowed!(mover: &Arc<_>, source_repo);
258-
259-
for cs in &css {
260-
if cs.is_merge() {
261-
return Err(anyhow!(
262-
"cannot remap merges in a stack - {}",
263-
cs.get_changeset_id()
264-
));
265-
}
266-
}
267-
268-
let css = stream::iter(css)
269-
.map({
270-
|cs| async move {
271-
let deleted_file_changes = if cs.file_changes().next().is_some() {
272-
let parents = cs.parents();
273-
get_renamed_implicit_deletes(
274-
ctx,
275-
cs.file_changes().collect(),
276-
parents,
277-
mover.clone(),
278-
source_repo,
279-
)
280-
.await?
281-
} else {
282-
vec![]
283-
};
284-
285-
anyhow::Ok((cs, deleted_file_changes))
286-
}
287-
})
288-
.buffered(100)
289-
.try_collect::<Vec<_>>()
290-
.await?;
291-
292-
let mut res = vec![];
293-
for (from_cs, renamed_implicit_deletes) in css {
294-
let from_cs_id = from_cs.get_changeset_id();
295-
let from_cs = from_cs.into_mut();
296-
297-
let mut remapped_parents = HashMap::new();
298-
if let Some(parent) = from_cs.parents.first() {
299-
remapped_parents.insert(*parent, rewritten_parent);
300-
}
301-
302-
let maybe_cs = rewrite_commit_with_implicit_deletes(
303-
ctx.logger(),
304-
from_cs,
305-
&remapped_parents,
306-
mover.clone(),
307-
vec![],
308-
force_first_parent,
309-
renamed_implicit_deletes,
310-
Default::default(),
311-
)?;
312-
313-
let maybe_cs = maybe_cs
314-
.map(|cs| modify_bonsai_cs((from_cs_id, cs)))
315-
.map(|bcs| bcs.freeze())
316-
.transpose()?;
317-
if let Some(ref cs) = maybe_cs {
318-
let to_cs_id = cs.get_changeset_id();
319-
rewritten_parent = to_cs_id;
320-
}
321-
322-
res.push(maybe_cs);
323-
}
324-
325-
Ok(res)
326-
}
327-
247+
// TODO(T182311609): reduce visibility to crate
328248
pub fn rewrite_commit_with_implicit_deletes<'a>(
329249
logger: &Logger,
330250
mut cs: BonsaiChangesetMut,

eden/mononoke/megarepo_api/commit_transformation/src/lib.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,25 @@ mod implicit_deletes;
1313
mod test;
1414
mod types;
1515

16-
// TODO(T182311609): stop exposing git_submodule directly in the public API
16+
// Re-exporting this module because there are many helper functions related to
17+
// submodules that might be needed by the callers.
1718
pub mod git_submodules;
1819

19-
// TODO(T182311609): refine exports
20-
pub use commit_rewriting::*;
20+
pub use commit_rewriting::copy_file_contents;
21+
pub use commit_rewriting::create_directory_source_to_target_multi_mover;
22+
pub use commit_rewriting::create_source_to_target_multi_mover;
23+
pub use commit_rewriting::rewrite_as_squashed_commit;
24+
pub use commit_rewriting::rewrite_commit;
25+
pub use commit_rewriting::rewrite_commit_with_file_changes_filter;
26+
pub use commit_rewriting::rewrite_commit_with_implicit_deletes;
27+
pub use commit_rewriting::upload_commits;
2128
pub use implicit_deletes::get_renamed_implicit_deletes;
29+
pub use types::CommitRewrittenToEmpty;
30+
pub use types::DirectoryMultiMover;
31+
pub use types::EmptyCommitFromLargeRepo;
32+
pub use types::MultiMover;
33+
pub use types::RewriteOpts;
34+
pub use types::StripCommitExtras;
2235
pub use types::SubmoduleDeps;
2336
pub use types::SubmoduleExpansionContentIds;
2437
pub use types::SubmodulePath;
25-
pub use types::*;

eden/mononoke/megarepo_api/commit_transformation/src/test.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ use tests_utils::list_working_copy_utf8;
4848
use tests_utils::CreateCommitContext;
4949

5050
use super::*;
51+
use crate::commit_rewriting::create_source_to_target_multi_mover;
5152
use crate::implicit_deletes::minimize_file_change_set;
53+
use crate::types::FileChangeFilter;
54+
use crate::types::FileChangeFilterApplication;
55+
use crate::types::FileChangeFilterFunc;
5256

5357
#[facet::container]
5458
#[derive(Clone)]

0 commit comments

Comments
 (0)