diff --git a/rust/hg-core/src/discovery.rs b/rust/hg-core/src/discovery.rs --- a/rust/hg-core/src/discovery.rs +++ b/rust/hg-core/src/discovery.rs @@ -198,19 +198,23 @@ )) } + fn get_common(&self) -> &MissingAncestors { + match self { + Com(c) => &c.common, + Und(u) => &u.common, + } + } + /// Do we have any information about the peer? pub fn has_info(&self) -> bool { - match self { - Com(c) => c.common.has_bases(), - Und(u) => u.has_info(), - } + self.get_common().has_bases() } /// Did we acquire full knowledge of our Revisions that the peer has? pub fn is_complete(&self) -> bool { match self { Com(_) => false, - Und(u) => u.is_complete(), + Und(u) => u.undecided.is_empty(), } } @@ -226,10 +230,7 @@ /// would be more appropriate for normal Rust callers, dropping `self` /// if it is complete. pub fn common_heads(&self) -> Result, GraphError> { - match self { - Com(c) => c.common.bases_heads(), - Und(u) => u.common_heads(), - } + self.get_common().bases_heads() } /// Provide statistics about the current state of the discovery process @@ -479,31 +480,6 @@ Ok(()) } - /// Do we have any information about the peer? - pub fn has_info(&self) -> bool { - self.common.has_bases() - } - - /// Did we acquire full knowledge of our Revisions that the peer has? - pub fn is_complete(&self) -> bool { - self.undecided.is_empty() - } - - /// Return the heads of the currently known common set of revisions. - /// - /// If the discovery process is not complete (see `is_complete()`), the - /// caller must be aware that this is an intermediate state. - /// - /// On the other hand, if it is complete, then this is currently - /// the only way to retrieve the end results of the discovery process. - /// - /// We may introduce in the future an `into_common_heads` call that - /// would be more appropriate for normal Rust callers, dropping `self` - /// if it is complete. - pub fn common_heads(&self) -> Result, GraphError> { - self.common.bases_heads() - } - fn compute_children_cache( graph: &G, undecided: impl Iterator,