D7722: rust-discovery: simplifying add_missing_revisions()

gracinet (Georges Racinet) phabricator at mercurial-scm.org
Tue Dec 24 08:50:43 EST 2019


gracinet created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  with the removal of the various ensure() it's become
  clear that this doesn't have error cases any more, and we didn't
  need the full match at the end.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7722

AFFECTED FILES
  rust/hg-core/src/discovery.rs

CHANGE DETAILS

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
@@ -266,7 +266,7 @@
 
         self.mutate_undecided(
             |oc| oc.compute_undecided(),
-            |wu| wu.add_missing_revisions(missing),
+            |wu| Ok(wu.add_missing_revisions(missing)),
         )
     }
 
@@ -456,10 +456,7 @@
     /// caller from `PartialDiscovery` can avoid the undecided set in case
     /// it turns out to be empty (hence restrain
     /// from performing the transition to `WithUndecided`)
-    pub fn add_missing_revisions(
-        &mut self,
-        mut tovisit: VecDeque<Revision>,
-    ) -> Result<(), GraphError> {
+    pub fn add_missing_revisions(&mut self, mut tovisit: VecDeque<Revision>) {
         let mut seen: HashSet<Revision> = HashSet::new();
         let undecided_mut = &mut self.undecided;
         let children = &self.children_cache;
@@ -473,20 +470,14 @@
                 continue;
             }
             undecided_mut.remove(&rev);
-            match children.get(&rev) {
-                None => {
-                    continue;
-                }
-                Some(this_children) => {
-                    for child in this_children.iter().cloned() {
-                        if seen.insert(child) {
-                            tovisit.push_back(child);
-                        }
+            if let Some(this_children) = children.get(&rev) {
+                for child in this_children.iter().cloned() {
+                    if seen.insert(child) {
+                        tovisit.push_back(child);
                     }
                 }
             }
         }
-        Ok(())
     }
 
     fn compute_children_cache(



To: gracinet, #hg-reviewers
Cc: durin42, kevincox, mercurial-devel


More information about the Mercurial-devel mailing list