[PATCH 1 of 4] rust-ancestors: adjust indent level to make next change easier to follow

Yuya Nishihara yuya at tcha.org
Sun Jan 6 03:54:04 UTC 2019


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1545223326 -32400
#      Wed Dec 19 21:42:06 2018 +0900
# Node ID e87cc0ce61a67f7fbc9c12ab1505a23e23b8217d
# Parent  25c142f679c23fbc210d5bcbdf2f913e4dd55402
rust-ancestors: adjust indent level to make next change easier to follow

diff --git a/rust/hg-core/src/ancestors.rs b/rust/hg-core/src/ancestors.rs
--- a/rust/hg-core/src/ancestors.rs
+++ b/rust/hg-core/src/ancestors.rs
@@ -341,40 +341,41 @@ impl<G: Graph> MissingAncestors<G> {
             // in Rust, one can't just use mutable variables assignation
             // to be more straightforward. Instead of Python's
             // thisvisit and othervisit, we'll differentiate with a boolean
-            let this_visit_is_revs = {
-                if revs_visit.remove(&curr) {
-                    missing.push(curr);
-                    true
-                } else if bases_visit.contains(&curr) {
-                    false
-                } else {
-                    // not an ancestor of revs or bases: ignore
-                    continue;
-                }
-            };
+            let this_visit_is_revs;
+            if revs_visit.remove(&curr) {
+                missing.push(curr);
+                this_visit_is_revs = true;
+            } else if bases_visit.contains(&curr) {
+                this_visit_is_revs = false;
+            } else {
+                // not an ancestor of revs or bases: ignore
+                continue;
+            }
 
-            for p in self.graph.parents(curr)?.iter().cloned() {
-                if p == NULL_REVISION {
-                    continue;
-                }
-                let in_other_visit = if this_visit_is_revs {
-                    bases_visit.contains(&p)
-                } else {
-                    revs_visit.contains(&p)
-                };
-                if in_other_visit || both_visit.contains(&p) {
-                    // p is implicitely in this_visit.
-                    // This means p is or should be in bothvisit
-                    // TODO optim: hence if bothvisit, we look up twice
-                    revs_visit.remove(&p);
-                    bases_visit.insert(p);
-                    both_visit.insert(p);
-                } else {
-                    // visit later
-                    if this_visit_is_revs {
-                        revs_visit.insert(p);
+            {
+                for p in self.graph.parents(curr)?.iter().cloned() {
+                    if p == NULL_REVISION {
+                        continue;
+                    }
+                    let in_other_visit = if this_visit_is_revs {
+                        bases_visit.contains(&p)
                     } else {
+                        revs_visit.contains(&p)
+                    };
+                    if in_other_visit || both_visit.contains(&p) {
+                        // p is implicitely in this_visit.
+                        // This means p is or should be in bothvisit
+                        // TODO optim: hence if bothvisit, we look up twice
+                        revs_visit.remove(&p);
                         bases_visit.insert(p);
+                        both_visit.insert(p);
+                    } else {
+                        // visit later
+                        if this_visit_is_revs {
+                            revs_visit.insert(p);
+                        } else {
+                            bases_visit.insert(p);
+                        }
                     }
                 }
             }


More information about the Mercurial-devel mailing list