Mercurial > hg-stable
changeset 51271:a8ca22119385
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.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 02 Nov 2023 15:50:13 +0100 |
parents | 2966b88d4531 |
children | 0409bd6ba663 |
files | rust/hg-cpython/src/revlog.rs |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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)