diff --git a/commit_rewriting/cross_repo_sync/src/lib.rs b/commit_rewriting/cross_repo_sync/src/lib.rs index aaa134f7bf..f427c12b1a 100644 --- a/commit_rewriting/cross_repo_sync/src/lib.rs +++ b/commit_rewriting/cross_repo_sync/src/lib.rs @@ -11,7 +11,6 @@ use std::collections::{BTreeMap, HashMap}; use blobrepo::{save_bonsai_changesets, BlobRepo}; use blobsync::copy_content; use bookmarks::BookmarkName; -use cloned::cloned; use context::CoreContext; use failure::{err_msg, Error, Fail}; use futures::Future; @@ -143,24 +142,20 @@ async fn remap_parents_and_rewrite_commit( target_repo_id: RepositoryId, mapping: &M, rewrite_path: Mover, -) -> Result)>, Error> { - let mut changesets_to_check: Vec = Vec::new(); +) -> Result, Error> { let mut remapped_parents = HashMap::new(); for commit in cs.parents.iter_mut() { let remapped_commit = mapping .get(ctx.clone(), source_repo_id, *commit, target_repo_id) .compat() .await?; - // If it doesn't remap, we will optimistically assume that the - // target is already in the repo - this is passed out - // to the caller to validate, as Mercurial has trouble if it's not true - let remapped_commit = remapped_commit.unwrap_or(*commit); - changesets_to_check.push(remapped_commit.clone()); + + let remapped_commit = + remapped_commit.ok_or(err_msg(format!("{} hasn't been remapped", *commit)))?; remapped_parents.insert(commit.clone(), remapped_commit); } - let cs = rewrite_commit(cs, &remapped_parents, rewrite_path)?; - Ok(cs.map(|cs| (cs, changesets_to_check))) + rewrite_commit(cs, &remapped_parents, rewrite_path) } #[derive(Clone)] @@ -338,31 +333,7 @@ pub async fn sync_commit( .await? { None => Ok(None), - Some((rewritten, changesets)) => { - // And check changesets are all in target - let changesets_check: FuturesUnordered<_> = changesets - .into_iter() - .map({ - |cs| { - cloned!(ctx, cs, target_repo); - async move { - if !target_repo - .changeset_exists_by_bonsai(ctx, cs) - .compat() - .await? - { - Err(ErrorKind::MissingRemappedCommit(cs).into()) - } else { - Ok(()) - } - } - } - }) - .collect(); - changesets_check - .try_for_each_concurrent(100, identity) - .await?; - + Some(rewritten) => { // Special case - commits with no parents (=> beginning of a repo) graft directly // to the bookmark, so that we can start a new sync with a fresh repo // Note that this won't work if the bookmark does not yet exist - don't do that diff --git a/tests/integration/test-cross-repo-commit-sync-merge.t b/tests/integration/test-cross-repo-commit-sync-merge.t index 0827a8891a..add4d953a1 100644 --- a/tests/integration/test-cross-repo-commit-sync-merge.t +++ b/tests/integration/test-cross-repo-commit-sync-merge.t @@ -78,9 +78,9 @@ run the sync, expected to fail, as parent of the synced commit is not present in * changeset resolved as: ChangesetId(Blake2(*)) (glob) * Checking if * is already synced 1->0 (glob) * Done preparing * (glob) - * Remapped commit * expected in target repo, but not present (glob) + * 3478f726ba230a5071ed5fc3ff32fb99738365cdf1a335830576e3c2664706c1 hasn't been remapped (glob) * Queue size is 0 (glob) - * Remapped commit * expected in target repo, but not present (glob) + * 3478f726ba230a5071ed5fc3ff32fb99738365cdf1a335830576e3c2664706c1 hasn't been remapped (glob) [1] insert sync mapping entry diff --git a/tests/integration/test-cross-repo-commit-sync.t b/tests/integration/test-cross-repo-commit-sync.t index 87f40b597d..cb4d3e08bf 100644 --- a/tests/integration/test-cross-repo-commit-sync.t +++ b/tests/integration/test-cross-repo-commit-sync.t @@ -112,9 +112,9 @@ run the sync, expected to fail, as parent of the synced commit is not present in * changeset resolved as: ChangesetId(Blake2(*)) (glob) * Checking if * is already synced 1->0 (glob) * Done preparing * (glob) - * Remapped commit * expected in target repo, but not present (glob) + * 3478f726ba230a5071ed5fc3ff32fb99738365cdf1a335830576e3c2664706c1 hasn't been remapped (glob) * Queue size is 0 (glob) - * Remapped commit * expected in target repo, but not present (glob) + * 3478f726ba230a5071ed5fc3ff32fb99738365cdf1a335830576e3c2664706c1 hasn't been remapped (glob) [1] insert sync mapping entry