rust-index: check rindex and cindex return the same get_rev
authorRaphaël Gomès <rgomes@octobus.net>
Thu, 29 Jun 2023 11:37:19 +0200
changeset 51196 f95f70cf2ee2
parent 51195 f6403bcd9f96
child 51197 4e6620b7fbbb
rust-index: check rindex and cindex return the same get_rev This is a temporary safeguard while we synchronize both indexes.
rust/hg-cpython/src/revlog.rs
--- a/rust/hg-cpython/src/revlog.rs	Wed Jun 28 16:43:39 2023 +0200
+++ b/rust/hg-cpython/src/revlog.rs	Thu Jun 29 11:37:19 2023 +0200
@@ -74,9 +74,15 @@
         let opt = self.get_nodetree(py)?.borrow();
         let nt = opt.as_ref().unwrap();
         let idx = &*self.cindex(py).borrow();
+        let ridx = &*self.index(py).borrow();
         let node = node_from_py_bytes(py, &node)?;
-        let res = nt.find_bin(idx, node.into());
-        Ok(res.map_err(|e| nodemap_error(py, e))?.map(Into::into))
+        let rust_rev =
+            nt.find_bin(ridx, node.into()).map_err(|e| nodemap_error(py, e))?;
+        let c_rev =
+            nt.find_bin(idx, node.into()).map_err(|e| nodemap_error(py, e))?;
+        assert_eq!(rust_rev, c_rev);
+        Ok(rust_rev.map(Into::into))
+
     }
 
     /// same as `get_rev()` but raises a bare `error.RevlogError` if node