add --no-merge flag

Summary:
This flag allows the repo import to progress through all the steps
but bail before actually merging in the repos.

Currently the repo_import tool is so slow that all the pre-merge steps
can take hours. This makes it really hard to control when the actual merge
commit will happen. This flag will allow us to prepare all those steps
ahead-of-time and then resume with just merge in mind.

I don't think it's a proper long-term fix but I found it useful when working
wath whatsapp/biz and would use it again util we properly optimize repo_import
tool.

Differential Revision: D46802952

fbshipit-source-id: 2e8185482c4ba9c04fed20013efcc80d75e80bad
This commit is contained in:
Mateusz Kwapich 2023-06-22 10:31:22 -07:00 committed by Facebook GitHub Bot
parent 0d05f5fcdb
commit 35d04fb79f
2 changed files with 22 additions and 1 deletions

View File

@ -92,6 +92,10 @@ pub struct MononokeRepoImportArgs {
/// The repository name or ID
#[clap(flatten)]
pub repo: RepoArgs,
/// Error out before the actual merge step. Useful for running all the a
/// earlier steps to prepare for merge time.
#[clap(long)]
pub no_merge: bool,
#[clap(subcommand)]
pub command: Option<Commands>,
}

View File

@ -1000,6 +1000,7 @@ async fn repo_import(
recovery_fields: &mut RecoveryFields,
configs: &RepoConfigs,
env: &MononokeEnvironment,
no_merge: bool,
) -> Result<(), Error> {
let arg_git_repo_path = recovery_fields.git_repo_path.clone();
let path = Path::new(&arg_git_repo_path);
@ -1283,6 +1284,12 @@ async fn repo_import(
save_importing_state(recovery_fields).await?;
}
if no_merge {
return Err(format_err!(
"Done everything but actual merge. Please resume without --no-merge flag"
));
}
if recovery_fields.import_stage == ImportStage::MergeCommits {
let maybe_merged_cs_id = Some(
merge_imported_commit(
@ -1538,7 +1545,17 @@ async fn async_main(app: MononokeApp) -> Result<(), Error> {
_ => return Err(format_err!("Invalid subcommand")),
};
match repo_import(&app, ctx, repo, &mut recovery_fields, &configs, env).await {
match repo_import(
&app,
ctx,
repo,
&mut recovery_fields,
&configs,
env,
args.no_merge,
)
.await
{
Ok(()) => Ok(()),
Err(e) => {
save_importing_state(&recovery_fields).await?;