changeset 51207:b67cd0d0e976

rust-index: add checks that `__contains__` is synchronized
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 02 Aug 2023 14:34:21 +0200
parents 952e3cd7568f
children 274abd1562a2
files rust/hg-cpython/src/revlog.rs
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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)
             }
         }
     }