rust-index: add support for `del index[r]`
Only the `del index[r:]` syntax was supported, but the comment said otherwise.
It's not actually used in core code, but the C index supports it.
--- a/rust/hg-cpython/src/revlog.rs Mon Oct 30 21:26:17 2023 +0100
+++ b/rust/hg-cpython/src/revlog.rs Thu Nov 02 15:50:13 2023 +0100
@@ -214,8 +214,12 @@
def __delitem__(&self, key: PyObject) -> PyResult<()> {
// __delitem__ is both for `del idx[r]` and `del idx[r1:r2]`
- let start = key.getattr(py, "start")?;
- let start = UncheckedRevision(start.extract(py)?);
+ let start = if let Ok(rev) = key.extract(py) {
+ UncheckedRevision(rev)
+ } else {
+ let start = key.getattr(py, "start")?;
+ UncheckedRevision(start.extract(py)?)
+ };
let start = self.index(py)
.borrow()
.check_revision(start)