Patchwork D8121: rust-dirstatemap: directly return `non_normal` and `other_entries`

login
register
mail settings
Submitter phabricator
Date Feb. 14, 2020, 4:49 p.m.
Message ID <46bfa1c42a35331e8eed5db78025c30b@localhost.localdomain>
Download mbox | patch
Permalink /patch/45238/
State Not Applicable
Headers show

Comments

phabricator - Feb. 14, 2020, 4:49 p.m.
Closed by commit rHGc089a0947f3e: rust-dirstatemap: directly return `non_normal` and `other_entries` (authored by Alphare).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8121?vs=20222&id=20223

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8121/new/

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: kevincox, mercurial-devel

Patch

diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -175,8 +175,7 @@ 
         locals.set_item(
             py,
             "other_parent",
-            other_parent.as_ref()
-                .unwrap()
+            other_parent
                 .iter()
                 .map(|v| PyBytes::new(py, v.as_ref()))
                 .collect::<Vec<PyBytes>>()
@@ -196,8 +195,6 @@ 
             .inner(py)
             .borrow_mut()
             .get_non_normal_other_parent_entries().0
-            .as_ref()
-            .unwrap()
             .contains(HgPath::new(key.data(py))))
     }
 
@@ -211,8 +208,7 @@ 
                         .inner(py)
                         .borrow_mut()
                         .get_non_normal_other_parent_entries().0
-                        .as_ref()
-                        .unwrap().iter().map(|o| o))
+                        .iter().map(|o| o))
                 )
             )
     }
diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -100,16 +100,12 @@ 
         if entry.state != EntryState::Normal || entry.mtime == MTIME_UNSET {
             self.get_non_normal_other_parent_entries()
                 .0
-                .as_mut()
-                .unwrap()
                 .insert(filename.to_owned());
         }
 
         if entry.size == SIZE_FROM_OTHER_PARENT {
             self.get_non_normal_other_parent_entries()
                 .1
-                .as_mut()
-                .unwrap()
                 .insert(filename.to_owned());
         }
         Ok(())
@@ -152,8 +148,6 @@ 
         );
         self.get_non_normal_other_parent_entries()
             .0
-            .as_mut()
-            .unwrap()
             .insert(filename.to_owned());
         Ok(())
     }
@@ -182,8 +176,6 @@ 
         }
         self.get_non_normal_other_parent_entries()
             .0
-            .as_mut()
-            .unwrap()
             .remove(filename);
 
         Ok(exists)
@@ -211,8 +203,6 @@ 
             if changed {
                 self.get_non_normal_other_parent_entries()
                     .0
-                    .as_mut()
-                    .unwrap()
                     .insert(filename.to_owned());
             }
         }
@@ -224,8 +214,6 @@ 
     ) -> bool {
         self.get_non_normal_other_parent_entries()
             .0
-            .as_mut()
-            .unwrap()
             .remove(key.as_ref())
     }
     pub fn non_normal_entries_union(
@@ -234,8 +222,6 @@ 
     ) -> Vec<HgPathBuf> {
         self.get_non_normal_other_parent_entries()
             .0
-            .as_mut()
-            .unwrap()
             .union(&other)
             .map(|e| e.to_owned())
             .collect()
@@ -243,12 +229,12 @@ 
 
     pub fn get_non_normal_other_parent_entries(
         &mut self,
-    ) -> (
-        &mut Option<HashSet<HgPathBuf>>,
-        &mut Option<HashSet<HgPathBuf>>,
-    ) {
+    ) -> (&mut HashSet<HgPathBuf>, &mut HashSet<HgPathBuf>) {
         self.set_non_normal_other_parent_entries(false);
-        (&mut self.non_normal_set, &mut self.other_parent_set)
+        (
+            self.non_normal_set.as_mut().unwrap(),
+            self.other_parent_set.as_mut().unwrap(),
+        )
     }
 
     pub fn set_non_normal_other_parent_entries(&mut self, force: bool) {
@@ -440,22 +426,8 @@ 
         .unwrap();
 
         assert_eq!(1, map.len());
-        assert_eq!(
-            0,
-            map.get_non_normal_other_parent_entries()
-                .0
-                .as_ref()
-                .unwrap()
-                .len()
-        );
-        assert_eq!(
-            0,
-            map.get_non_normal_other_parent_entries()
-                .1
-                .as_ref()
-                .unwrap()
-                .len()
-        );
+        assert_eq!(0, map.get_non_normal_other_parent_entries().0.len());
+        assert_eq!(0, map.get_non_normal_other_parent_entries().1.len());
     }
 
     #[test]
@@ -487,7 +459,7 @@ 
         })
         .collect();
 
-        let non_normal = [
+        let mut non_normal = [
             b"f1", b"f2", b"f5", b"f6", b"f7", b"f8", b"f9", b"fa", b"fb",
         ]
         .iter()
@@ -499,8 +471,8 @@ 
         let entries = map.get_non_normal_other_parent_entries();
 
         assert_eq!(
-            (Some(non_normal), Some(other_parent)),
-            (entries.0.to_owned(), entries.1.to_owned())
+            (&mut non_normal, &mut other_parent),
+            (entries.0, entries.1)
         );
     }
 }