megarepo_add_branching_sync_target method

Summary: This new method will allow the megarepo customers to create a sync target that's branching off the existing target. This feature is meant to be used for release branches.

Reviewed By: StanislavGlebik

Differential Revision: D29275281

fbshipit-source-id: 7b58d5cc49c99bbc5f7e01814178376aa3abfcdf
This commit is contained in:
Mateusz Kwapich 2021-07-09 04:40:05 -07:00 committed by Facebook GitHub Bot
parent ee57c22f5e
commit 3a41e7fbc3
4 changed files with 124 additions and 18 deletions

View File

@ -20,30 +20,35 @@ use megarepo_types_thrift::{
use mononoke_types::{hash::Blake2, impl_typed_context, impl_typed_hash_no_context};
use requests_table::RowId;
use source_control::{
MegarepoAddBranchingTargetParams as ThriftMegarepoAddBranchingTargetParams,
MegarepoAddTargetParams as ThriftMegarepoAddTargetParams,
MegarepoChangeTargetConfigParams as ThriftMegarepoChangeTargetConfigParams,
MegarepoRemergeSourceParams as ThriftMegarepoRemergeSourceParams,
MegarepoSyncChangesetParams as ThriftMegarepoSyncChangesetParams,
};
use source_control::{
MegarepoAddBranchingTargetPollResponse as ThriftMegarepoAddBranchingTargetPollResponse,
MegarepoAddTargetPollResponse as ThriftMegarepoAddTargetPollResponse,
MegarepoChangeTargetConfigPollResponse as ThriftMegarepoChangeTargetConfigPollResponse,
MegarepoRemergeSourcePollResponse as ThriftMegarepoRemergeSourcePollResponse,
MegarepoSyncChangesetPollResponse as ThriftMegarepoSyncChangesetPollResponse,
};
use source_control::{
MegarepoAddBranchingTargetResponse as ThriftMegarepoAddBranchingTargetResponse,
MegarepoAddTargetResponse as ThriftMegarepoAddTargetResponse,
MegarepoChangeTargetConfigResponse as ThriftMegarepoChangeTargetConfigResponse,
MegarepoRemergeSourceResponse as ThriftMegarepoRemergeSourceResponse,
MegarepoSyncChangesetResponse as ThriftMegarepoSyncChangesetResponse,
};
use source_control::{
MegarepoAddBranchingTargetResult as ThriftMegarepoAddBranchingTargetResult,
MegarepoAddTargetResult as ThriftMegarepoAddTargetResult,
MegarepoChangeTargetConfigResult as ThriftMegarepoChangeTargetConfigResult,
MegarepoRemergeSourceResult as ThriftMegarepoRemergeSourceResult,
MegarepoSyncChangesetResult as ThriftMegarepoSyncChangesetResult,
};
use source_control::{
MegarepoAddBranchingTargetToken as ThriftMegarepoAddBranchingTargetToken,
MegarepoAddTargetToken as ThriftMegarepoAddTargetToken,
MegarepoChangeConfigToken as ThriftMegarepoChangeConfigToken,
MegarepoRemergeSourceToken as ThriftMegarepoRemergeSourceToken,
@ -425,6 +430,28 @@ impl_async_svc_method_types! {
}
}
// Params and result types for megarepo_add_sync_target
impl_async_svc_method_types! {
method_name => "megarepo_add_branching_sync_target",
request_struct => MegarepoAddBranchingSyncTarget,
params_value_thrift_type => ThriftMegarepoAddBranchingTargetParams,
params_union_variant => megarepo_add_branching_target_params,
result_value_thrift_type => ThriftMegarepoAddBranchingTargetResult,
result_union_variant => megarepo_add_branching_target_result,
response_type => ThriftMegarepoAddBranchingTargetResponse,
poll_response_type => ThriftMegarepoAddBranchingTargetPollResponse,
token_type => MegarepoAddBranchingTargetToken,
token_thrift_type => ThriftMegarepoAddBranchingTargetToken,
fn target(&self: ThriftParams) -> &Target {
&self.target
}
}
// Params and result types for megarepo_change_target_config
impl_async_svc_method_types! {
@ -513,6 +540,9 @@ impl MegarepoAsynchronousRequestParams {
ThriftMegarepoAsynchronousRequestParams::megarepo_add_target_params(params) => {
Ok(params.target())
}
ThriftMegarepoAsynchronousRequestParams::megarepo_add_branching_target_params(
params,
) => Ok(params.target()),
ThriftMegarepoAsynchronousRequestParams::megarepo_change_target_params(params) => {
Ok(params.target())
}

View File

@ -97,6 +97,12 @@ pub(crate) async fn megarepo_async_request_compute(
.await
.into()
}
megarepo_types_thrift::MegarepoAsynchronousRequestParams::megarepo_add_branching_target_params(_params) => {
Err::<thrift::MegarepoChangeTargetConfigResponse, _>(MegarepoError::internal(anyhow!(
"add_branching_sync_target is not implemented yet!",
)))
.into()
}
megarepo_types_thrift::MegarepoAsynchronousRequestParams::megarepo_change_target_params(params) => {
megarepo_change_target_config(ctx, megarepo_api, params)
.await

View File

@ -5,7 +5,6 @@
* GNU General Public License version 2.
*/
//! Thrift types for megarepo async service methods
//! These aren't part of `source_control.trift`, because they aren't part of
//! the service interface. They aren't part of of `megarepo_configs.thrift`,
@ -14,31 +13,54 @@
include "eden/mononoke/mononoke_types/if/mononoke_types_thrift.thrift"
include "eden/mononoke/scs/if/source_control.thrift"
// Id types for async service methods params and responses.
// Param and response types themselves are defined in the source_control.trift
typedef mononoke_types_thrift.IdType MegarepoAddTargetParamsId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoChangeTargetConfigParamsId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoRemergeSourceParamsId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoSyncChangesetParamsId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoAddBranchingTargetParamsId (
rust.newtype,
)
typedef mononoke_types_thrift.IdType MegarepoChangeTargetConfigParamsId (
rust.newtype,
)
typedef mononoke_types_thrift.IdType MegarepoRemergeSourceParamsId (
rust.newtype,
)
typedef mononoke_types_thrift.IdType MegarepoSyncChangesetParamsId (
rust.newtype,
)
typedef mononoke_types_thrift.IdType MegarepoSyncChangesetResultId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoSyncChangesetResultId (
rust.newtype,
)
typedef mononoke_types_thrift.IdType MegarepoAddTargetResultId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoRemergeSourceResultId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoChangeTargetConfigResultId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoAddBranchingTargetResultId (
rust.newtype,
)
typedef mononoke_types_thrift.IdType MegarepoRemergeSourceResultId (
rust.newtype,
)
typedef mononoke_types_thrift.IdType MegarepoChangeTargetConfigResultId (
rust.newtype,
)
typedef mononoke_types_thrift.IdType MegarepoAsynchronousRequestResultId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoAsynchronousRequestResultId (
rust.newtype,
)
union MegarepoAsynchronousRequestResult {
1: source_control.MegarepoAddTargetResult megarepo_add_target_result,
2: source_control.MegarepoChangeTargetConfigResult megarepo_change_target_result,
3: source_control.MegarepoRemergeSourceResult megarepo_remerge_source_result,
4: source_control.MegarepoSyncChangesetResult megarepo_sync_changeset_result,
1: source_control.MegarepoAddTargetResult megarepo_add_target_result;
2: source_control.MegarepoChangeTargetConfigResult megarepo_change_target_result;
3: source_control.MegarepoRemergeSourceResult megarepo_remerge_source_result;
4: source_control.MegarepoSyncChangesetResult megarepo_sync_changeset_result;
5: source_control.MegarepoAddBranchingTargetResult megarepo_add_branching_target_result;
}
typedef mononoke_types_thrift.IdType MegarepoAsynchronousRequestParamsId (rust.newtype)
typedef mononoke_types_thrift.IdType MegarepoAsynchronousRequestParamsId (
rust.newtype,
)
union MegarepoAsynchronousRequestParams {
1: source_control.MegarepoAddTargetParams megarepo_add_target_params,
2: source_control.MegarepoChangeTargetConfigParams megarepo_change_target_params,
3: source_control.MegarepoRemergeSourceParams megarepo_remerge_source_params,
4: source_control.MegarepoSyncChangesetParams megarepo_sync_changeset_params,
1: source_control.MegarepoAddTargetParams megarepo_add_target_params;
2: source_control.MegarepoChangeTargetConfigParams megarepo_change_target_params;
3: source_control.MegarepoRemergeSourceParams megarepo_remerge_source_params;
4: source_control.MegarepoSyncChangesetParams megarepo_sync_changeset_params;
5: source_control.MegarepoAddBranchingTargetParams megarepo_add_branching_target_params;
}

View File

@ -945,6 +945,13 @@ struct MegarepoAddTargetToken {
2: i64 id,
}
struct MegarepoAddBranchingTargetToken {
// A target this token relates to
1: megarepo_configs.Target target,
// An actual token payload
2: i64 id,
}
// Params for the megarepo_add_sync_target_config method
struct MegarepoAddConfigParams {
// New config to be added to the config library
@ -979,6 +986,16 @@ struct MegarepoAddTargetParams {
3: optional string message,
}
// Params for megarepo_add_sync_target method
struct MegarepoAddBranchingTargetParams {
// A new target to be created
1: megarepo_configs.Target target,
// The specified commit will be used as parent of the first commit in the
// newly created target. The megarepo config used to create the branching
// point will be used as the base for the new target config.
2: megarepo_configs.ChangesetId branching_point,
}
// Params for megarepo_change_target_config method
struct MegarepoChangeTargetConfigParams {
// A target for which to change the version
@ -1250,6 +1267,21 @@ struct MegarepoAddTargetPollResponse {
1: optional MegarepoAddTargetResult result,
}
struct MegarepoAddBranchingTargetResponse {
// A new position of the target bookmark
1: megarepo_configs.ChangesetId cs_id
}
union MegarepoAddBranchingTargetResult {
1: MegarepoAddBranchingTargetResponse success,
2: MegarepoAsynchronousRequestError error,
}
struct MegarepoAddBranchingTargetPollResponse {
// Maybe a response to an underlying call, if it is ready
1: optional MegarepoAddBranchingTargetResult result,
}
struct MegarepoChangeTargetConfigResponse {
// A new position of the target bookmark
// after the "change config" operaton finished
@ -1664,6 +1696,22 @@ service SourceControlService extends fb303.FacebookService {
2: InternalError internal_error,
)
// Add a new target that branches off existing target.
MegarepoAddBranchingTargetToken megarepo_add_branching_sync_target(
1: MegarepoAddBranchingTargetParams params
) throws (
1: RequestError request_error,
2: InternalError internal_error,
),
/// Poll the execution of megarepo_add_sync_target request
MegarepoAddBranchingTargetPollResponse megarepo_add_branching_sync_target_poll(
1: MegarepoAddBranchingTargetToken token
) throws (
1: RequestError request_error,
2: InternalError internal_error,
)
// Set target's version to a new value while applying necessary transformations
// These transformations may include:
// - deletions of old mappings of sources that need to be re-merged