mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 09:48:05 +03:00
mononoke: fail if parent commit hasn't been remapped
Summary: We've changed data model to make sure we have entry for all pre-big merge commits. This diff removes the checks for non-remapped commits in the target repo - those shouldn't be necessary anymore. Reviewed By: farnz Differential Revision: D18084127 fbshipit-source-id: 6fa00ac59f5d0806035b1a4f590344e800a4c174
This commit is contained in:
parent
d54269bd17
commit
eee72e2a04
@ -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<M: SyncedCommitMapping>(
|
||||
target_repo_id: RepositoryId,
|
||||
mapping: &M,
|
||||
rewrite_path: Mover,
|
||||
) -> Result<Option<(BonsaiChangesetMut, Vec<ChangesetId>)>, Error> {
|
||||
let mut changesets_to_check: Vec<ChangesetId> = Vec::new();
|
||||
) -> Result<Option<BonsaiChangesetMut>, 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<M: SyncedCommitMapping + Clone + 'static>(
|
||||
.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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user