rust-index: add checks that `__contains__` is synchronized
authorRaphaël Gomès <rgomes@octobus.net>
Wed, 02 Aug 2023 14:34:21 +0200
changeset 51207 b67cd0d0e976
parent 51206 952e3cd7568f
child 51208 274abd1562a2
rust-index: add checks that `__contains__` is synchronized
rust/hg-cpython/src/revlog.rs
--- a/rust/hg-cpython/src/revlog.rs	Mon Oct 30 11:03:57 2023 +0100
+++ b/rust/hg-cpython/src/revlog.rs	Wed Aug 02 14:34:21 2023 +0200
@@ -324,12 +324,18 @@
                 Ok(rev >= -1 && rev < self.len(py)? as BaseRevision)
             }
             Err(_) => {
-                cindex.inner().call_method(
+                let item_bytes: PyBytes = item.extract(py)?;
+                let rust_res = self.has_node(py, item_bytes)?;
+
+                let c_res = cindex.inner().call_method(
                     py,
                     "has_node",
-                    PyTuple::new(py, &[item]),
+                    PyTuple::new(py, &[item.clone_ref(py)]),
                     None)?
-                .extract(py)
+                .extract(py)?;
+
+                assert_eq!(rust_res, c_res);
+                Ok(rust_res)
             }
         }
     }