mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 06:47:41 +03:00
edenapi: add pull_lazy client-side implementation
Summary: This will replace pull_fast_forward_master. Reviewed By: DurhamG Differential Revision: D33594527 fbshipit-source-id: a8a52567ec2395978228f4c3bf5ff385ad0e6d46
This commit is contained in:
parent
5600b0f82f
commit
1da6f656d6
@ -107,6 +107,7 @@ use crate::retryable::RetryableFiles;
|
||||
use crate::retryable::RetryableStreamRequest;
|
||||
use crate::retryable::RetryableTrees;
|
||||
use crate::types::wire::pull::PullFastForwardRequest;
|
||||
use crate::types::wire::pull::PullLazyRequest;
|
||||
|
||||
/// All non-alphanumeric characters (except hypens, underscores, and periods)
|
||||
/// found in the repo's name will be percent-encoded before being used in URLs.
|
||||
@ -131,6 +132,7 @@ mod paths {
|
||||
pub const COMMIT_REVLOG_DATA: &str = "commit/revlog_data";
|
||||
pub const CLONE_DATA: &str = "clone";
|
||||
pub const PULL_FAST_FORWARD: &str = "pull_fast_forward_master";
|
||||
pub const PULL_LAZY: &str = "pull_lazy";
|
||||
pub const COMMIT_LOCATION_TO_HASH: &str = "commit/location_to_hash";
|
||||
pub const COMMIT_HASH_TO_LOCATION: &str = "commit/hash_to_location";
|
||||
pub const COMMIT_HASH_LOOKUP: &str = "commit/hash_lookup";
|
||||
@ -522,6 +524,21 @@ impl Client {
|
||||
})?
|
||||
}
|
||||
|
||||
async fn pull_lazy_attempt(
|
||||
&self,
|
||||
req: PullLazyRequest,
|
||||
) -> Result<CloneData<HgId>, EdenApiError> {
|
||||
let url = self.build_url(paths::PULL_LAZY)?;
|
||||
let req = self
|
||||
.configure_request(self.inner.client.post(url))?
|
||||
.cbor(&req.to_wire())
|
||||
.map_err(EdenApiError::RequestSerializationFailed)?;
|
||||
let mut fetch = self.fetch::<CloneData<HgId>>(vec![req])?;
|
||||
fetch.entries.next().await.ok_or_else(|| {
|
||||
EdenApiError::Other(format_err!("clone data missing from reponse body"))
|
||||
})?
|
||||
}
|
||||
|
||||
async fn fast_forward_pull_attempt(
|
||||
&self,
|
||||
req: PullFastForwardRequest,
|
||||
@ -794,6 +811,26 @@ impl EdenApi for Client {
|
||||
.await
|
||||
}
|
||||
|
||||
async fn pull_lazy(
|
||||
&self,
|
||||
common: Vec<HgId>,
|
||||
missing: Vec<HgId>,
|
||||
) -> Result<CloneData<HgId>, EdenApiError> {
|
||||
tracing::info!(
|
||||
"Requesting pull lazy data for the '{}' repository",
|
||||
self.repo_name()
|
||||
);
|
||||
|
||||
self.with_retry(|this| {
|
||||
let req = PullLazyRequest {
|
||||
common: common.clone(),
|
||||
missing: missing.clone(),
|
||||
};
|
||||
this.pull_lazy_attempt(req).boxed()
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
async fn commit_location_to_hash(
|
||||
&self,
|
||||
requests: Vec<CommitLocationToHashRequest>,
|
||||
|
Loading…
Reference in New Issue
Block a user