Skip to content

Commit

Permalink
regerepo: add to_set() function
Browse files Browse the repository at this point in the history
Summary: add `to_set()` util, this simplifies the transform logic from HgId to dag::Set.

Reviewed By: quark-zju

Differential Revision: D64187444

fbshipit-source-id: e2bca4601378a2475a6e3976be9e0735ac1ce7c1
  • Loading branch information
zzl0 authored and facebook-github-bot committed Oct 11, 2024
1 parent b7955b1 commit c8344f2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions eden/scm/lib/eagerepo/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,10 @@ impl SaplingRemoteApi for EagerRepo {

debug!("pull_lazy");
self.refresh_for_api();
let common = to_vec_vertex(&common);
let missing = to_vec_vertex(&missing);
let set = self
.dag()
.await
.only(
Set::from_static_names(missing),
Set::from_static_names(common),
)
.only(to_set(&missing), to_set(&common))
.await
.map_err(map_dag_err)?;
let clone_data = self
Expand Down Expand Up @@ -562,8 +557,8 @@ impl SaplingRemoteApi for EagerRepo {
debug_hgid_list(&common),
);
self.refresh_for_api();
let heads = Set::from_static_names(heads.iter().map(|v| Vertex::copy_from(v.as_ref())));
let common = Set::from_static_names(common.iter().map(|v| Vertex::copy_from(v.as_ref())));
let heads = to_set(&heads);
let common = to_set(&common);
let graph = self
.dag()
.await
Expand Down Expand Up @@ -608,8 +603,8 @@ impl SaplingRemoteApi for EagerRepo {
debug_hgid_list(&common),
);
self.refresh_for_api();
let heads = Set::from_static_names(heads.iter().map(|v| Vertex::copy_from(v.as_ref())));
let common = Set::from_static_names(common.iter().map(|v| Vertex::copy_from(v.as_ref())));
let heads = to_set(&heads);
let common = to_set(&common);
let graph = self
.dag()
.await
Expand Down Expand Up @@ -1560,6 +1555,11 @@ fn to_vec_vertex(ids: &[HgId]) -> Vec<Vertex> {
ids.iter().map(|i| Vertex::copy_from(i.as_ref())).collect()
}

fn to_set(ids: &[HgId]) -> Set {
let vertexes = to_vec_vertex(ids);
Set::from_static_names(vertexes)
}

fn convert_clone_data(clone_data: dag::CloneData<Vertex>) -> edenapi::Result<dag::CloneData<HgId>> {
check_convert_to_hgid(clone_data.idmap.values())?;
let clone_data = dag::CloneData {
Expand Down

0 comments on commit c8344f2

Please sign in to comment.