mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 00:45:18 +03:00
hgcommits: use HashMap, not function to provide parents
Summary: See the previous diff for context. A concrete HashMap can provide "hint_pending_subdag". But a parent function cannot. Reviewed By: sfilipco Differential Revision: D27629311 fbshipit-source-id: 65168a8d00d9a672396312200016d6749f416d02
This commit is contained in:
parent
917cf2c9bb
commit
d453c93b96
@ -102,17 +102,11 @@ impl AppendCommits for HgCommits {
|
||||
}
|
||||
|
||||
// Write commit graph to DAG.
|
||||
let commits_map: HashMap<Vertex, HgCommit> = commits
|
||||
let parents: HashMap<Vertex, Vec<Vertex>> = commits
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|c| (c.vertex.clone(), c))
|
||||
.map(|c| (c.vertex, c.parents))
|
||||
.collect();
|
||||
let parent_func = move |v: Vertex| -> dag::Result<Vec<Vertex>> {
|
||||
match commits_map.get(&v) {
|
||||
Some(commit) => Ok(commit.parents.clone()),
|
||||
None => v.not_found(),
|
||||
}
|
||||
};
|
||||
let heads: Vec<Vertex> = {
|
||||
let mut non_heads = HashSet::new();
|
||||
for commit in commits {
|
||||
@ -127,9 +121,7 @@ impl AppendCommits for HgCommits {
|
||||
.cloned()
|
||||
.collect()
|
||||
};
|
||||
let parent_func: Box<dyn Fn(Vertex) -> dag::Result<Vec<Vertex>> + Send + Sync> =
|
||||
Box::new(parent_func);
|
||||
self.dag.add_heads(&parent_func, &heads).await?;
|
||||
self.dag.add_heads(&parents, &heads).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user