# HG changeset patch # User Raphaël Gomès # Date 1698936613 -3600 # Node ID a8ca22119385facc1d17813272ab0ed044330ffe # Parent 2966b88d45317aed8a95397b58c999c70cb81074 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. diff -r 2966b88d4531 -r a8ca22119385 rust/hg-cpython/src/revlog.rs --- 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)