Skip to content

Commit

Permalink
a method to reverse the syncer
Browse files Browse the repository at this point in the history
Differential Revision: D54965426

fbshipit-source-id: b7f4527566ee1775041bb50619faf39fcff70e1a
  • Loading branch information
mitrandir77 authored and facebook-github-bot committed Mar 18, 2024
1 parent 02e31ad commit 205c588
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ where
}
}

// Builds the syncer that can be used for opposite sync direction.
// Note: doesn't support large-to-small as input right now
pub fn reverse(&self) -> Result<CommitSyncer<M, R>, Error> {
Ok(Self {
mapping: self.mapping.clone(),
repos: self.repos.reverse()?,
live_commit_sync_config: self.live_commit_sync_config.clone(),
scuba_sample: self.scuba_sample.clone(),
x_repo_sync_lease: self.x_repo_sync_lease.clone(),
})
}

// ------------------------------------------------------------------------
// Sync methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,24 @@ impl<R: Repo> CommitSyncRepos<R> {
}
}

// Builds the repos that can be used for opposite sync direction.
// Note: doesn't support large-to-small as input right now
pub fn reverse(&self) -> Result<Self> {
match self {
CommitSyncRepos::LargeToSmall { .. } => Err(anyhow!(
"reversing sync direction is only supported for small to large sync (because of submodule dependencies)"
)),
CommitSyncRepos::SmallToLarge {
large_repo,
small_repo,
..
} => Ok(CommitSyncRepos::LargeToSmall {
large_repo: large_repo.clone(),
small_repo: small_repo.clone(),
}),
}
}

pub fn get_submodule_deps(&self) -> &SubmoduleDeps<R> {
match self {
CommitSyncRepos::LargeToSmall { .. } => &SubmoduleDeps::NotNeeded,
Expand Down

0 comments on commit 205c588

Please sign in to comment.