Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-cpython/src/revlog.rs @ 51224:7434747343ab
rust-index: check that the entry bytes are the same in both indexes
This is a temporary measure to show that both the Rust and C indexes are
kept in sync.
Comes with some related documentation precisions.
For comparison of error cases, see `index_entry_binary()` in `revlog.c`.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Thu, 02 Nov 2023 11:16:13 +0100 |
parents | 16d477bb0078 |
children | 297fa956b6c4 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/revlog.rs Sat Sep 30 16:15:56 2023 +0200 +++ b/rust/hg-cpython/src/revlog.rs Thu Nov 02 11:16:13 2023 +0100 @@ -211,7 +211,16 @@ /// return the raw binary string representing a revision def entry_binary(&self, *args, **kw) -> PyResult<PyObject> { - self.call_cindex(py, "entry_binary", args, kw) + let rindex = self.index(py).borrow(); + let rev = UncheckedRevision(args.get_item(py, 0).extract(py)?); + let rust_bytes = rindex.check_revision(rev).and_then( + |r| rindex.entry_binary(r)) + .ok_or_else(|| rev_not_in_index(py, rev))?; + let rust_res = PyBytes::new(py, rust_bytes).into_object(); + + let c_res = self.call_cindex(py, "entry_binary", args, kw)?; + assert_py_eq(py, "entry_binary", &rust_res, &c_res)?; + Ok(rust_res) } /// return a binary packed version of the header @@ -615,7 +624,6 @@ ) } -#[allow(dead_code)] fn rev_not_in_index(py: Python, rev: UncheckedRevision) -> PyErr { PyErr::new::<ValueError, _>( py,