Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/discovery.rs @ 42180:1b0be75cb61f
rust-discovery: implementing and exposing stats()
This time, it's simple enough that we can do it in all layers in
one shot.
Differential Revision: https://phab.mercurial-scm.org/D6233
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Thu, 14 Mar 2019 17:57:31 +0000 |
parents | 10b465d61556 |
children | 388622cbc911 |
line wrap: on
line diff
--- a/rust/hg-core/src/discovery.rs Wed Feb 20 09:04:39 2019 +0100 +++ b/rust/hg-core/src/discovery.rs Thu Mar 14 17:57:31 2019 +0000 @@ -23,6 +23,10 @@ missing: HashSet<Revision>, } +pub struct DiscoveryStats { + pub undecided: Option<usize>, +} + impl<G: Graph + Clone> PartialDiscovery<G> { /// Create a PartialDiscovery object, with the intent /// of comparing our `::<target_heads>` revset to the contents of another @@ -119,6 +123,13 @@ Some(self.common.missing_ancestors(tgt)?.into_iter().collect()); Ok(()) } + + /// Provide statistics about the current state of the discovery process + pub fn stats(&self) -> DiscoveryStats { + DiscoveryStats { + undecided: self.undecided.as_ref().map(|s| s.len()), + } + } } #[cfg(test)] @@ -161,6 +172,7 @@ let mut disco = full_disco(); assert_eq!(disco.undecided, None); assert!(!disco.has_info()); + assert_eq!(disco.stats().undecided, None); disco.add_common_revisions(vec![11, 12])?; assert!(disco.has_info()); @@ -172,6 +184,7 @@ assert_eq!(disco.undecided, None); disco.ensure_undecided()?; assert_eq!(sorted_undecided(&disco), vec![5, 8, 10, 13]); + assert_eq!(disco.stats().undecided, Some(4)); Ok(()) }