Mercurial > hg
comparison rust/hg-cpython/src/revlog.rs @ 51250: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 |
comparison
equal
deleted
inserted
replaced
51249:2966b88d4531 | 51250:a8ca22119385 |
---|---|
212 Ok(py.None()) | 212 Ok(py.None()) |
213 } | 213 } |
214 | 214 |
215 def __delitem__(&self, key: PyObject) -> PyResult<()> { | 215 def __delitem__(&self, key: PyObject) -> PyResult<()> { |
216 // __delitem__ is both for `del idx[r]` and `del idx[r1:r2]` | 216 // __delitem__ is both for `del idx[r]` and `del idx[r1:r2]` |
217 let start = key.getattr(py, "start")?; | 217 let start = if let Ok(rev) = key.extract(py) { |
218 let start = UncheckedRevision(start.extract(py)?); | 218 UncheckedRevision(rev) |
219 } else { | |
220 let start = key.getattr(py, "start")?; | |
221 UncheckedRevision(start.extract(py)?) | |
222 }; | |
219 let start = self.index(py) | 223 let start = self.index(py) |
220 .borrow() | 224 .borrow() |
221 .check_revision(start) | 225 .check_revision(start) |
222 .ok_or_else(|| { | 226 .ok_or_else(|| { |
223 nodemap_error(py, NodeMapError::RevisionNotInIndex(start)) | 227 nodemap_error(py, NodeMapError::RevisionNotInIndex(start)) |