mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
eagerepo: implement EdenApi "commit_location_to_hash" endpoint
Summary: Implement the endpoint. Most of the complexity is type conversion. Reviewed By: andll Differential Revision: D27929201 fbshipit-source-id: b96f65a0173a31f716272c8e0dd47ce8a90759cd
This commit is contained in:
parent
fc55fab9f9
commit
5920b3b927
@ -7,6 +7,9 @@
|
||||
|
||||
use crate::EagerRepo;
|
||||
use dag::ops::DagExportCloneData;
|
||||
use dag::protocol::AncestorPath;
|
||||
use dag::protocol::RemoteIdConvertProtocol;
|
||||
use dag::Location;
|
||||
use dag::Vertex;
|
||||
use edenapi::types::BookmarkEntry;
|
||||
use edenapi::types::CommitHashToLocationResponse;
|
||||
@ -212,7 +215,44 @@ impl EdenApi for EagerRepo {
|
||||
requests: Vec<CommitLocationToHashRequest>,
|
||||
_progress: Option<ProgressCallback>,
|
||||
) -> edenapi::Result<Fetch<CommitLocationToHashResponse>> {
|
||||
todo!()
|
||||
let path_names: Vec<(AncestorPath, Vec<Vertex>)> = {
|
||||
let paths: Vec<AncestorPath> = requests
|
||||
.into_iter()
|
||||
.map(|r| AncestorPath {
|
||||
x: Vertex::copy_from(r.location.descendant.as_ref()),
|
||||
n: r.location.distance,
|
||||
batch_size: r.count,
|
||||
})
|
||||
.collect();
|
||||
self.dag()
|
||||
.resolve_relative_paths_to_names(paths)
|
||||
.await
|
||||
.map_err(map_dag_err)?
|
||||
};
|
||||
|
||||
check_convert_to_hgid(path_names.iter().flat_map(|i| i.1.iter()))?;
|
||||
check_convert_to_hgid(path_names.iter().map(|i| &i.0.x))?;
|
||||
|
||||
let values: Vec<edenapi::Result<CommitLocationToHashResponse>> = path_names
|
||||
.into_iter()
|
||||
.map(|(p, ns)| {
|
||||
let count = ns.len();
|
||||
let response = CommitLocationToHashResponse {
|
||||
location: Location {
|
||||
descendant: HgId::from_slice(p.x.as_ref()).unwrap(), // unwrap: checked above
|
||||
distance: p.n,
|
||||
},
|
||||
hgids: ns
|
||||
.into_iter()
|
||||
.map(|n| HgId::from_slice(n.as_ref()).unwrap()) // unwrap: checked above
|
||||
.collect(),
|
||||
count: count as _,
|
||||
};
|
||||
Ok(response)
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(convert_to_fetch(values))
|
||||
}
|
||||
|
||||
async fn commit_hash_to_location(
|
||||
|
Loading…
Reference in New Issue
Block a user