Mercurial > hg
comparison rust/hg-cpython/src/dirstate/dirstate_map.rs @ 43273:478d0b1bf0c5
rust-dirstate-status: rust-cpython bindings for `dirstate.status`
The ref-sharing mechanism has improved, but its ergonomics still left a bit
to be desired, as expected.
Differential Revision: https://phab.mercurial-scm.org/D7059
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Tue, 08 Oct 2019 08:45:55 +0200 |
parents | 1ca3823aeefd |
children | ce6dd1cee4c8 |
comparison
equal
deleted
inserted
replaced
43272:00222775d59b | 43273:478d0b1bf0c5 |
---|---|
6 // GNU General Public License version 2 or any later version. | 6 // GNU General Public License version 2 or any later version. |
7 | 7 |
8 //! Bindings for the `hg::dirstate::dirstate_map` file provided by the | 8 //! Bindings for the `hg::dirstate::dirstate_map` file provided by the |
9 //! `hg-core` package. | 9 //! `hg-core` package. |
10 | 10 |
11 use std::cell::RefCell; | 11 use std::cell::{Ref, RefCell}; |
12 use std::convert::TryInto; | 12 use std::convert::TryInto; |
13 use std::time::Duration; | 13 use std::time::Duration; |
14 | 14 |
15 use cpython::{ | 15 use cpython::{ |
16 exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyObject, | 16 exc, ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyObject, |
463 } | 463 } |
464 | 464 |
465 }); | 465 }); |
466 | 466 |
467 impl DirstateMap { | 467 impl DirstateMap { |
468 pub fn get_inner<'a>( | |
469 &'a self, | |
470 py: Python<'a>, | |
471 ) -> Ref<'a, RustDirstateMap> { | |
472 self.inner_shared(py).borrow() | |
473 } | |
468 fn translate_key( | 474 fn translate_key( |
469 py: Python, | 475 py: Python, |
470 res: (&HgPathBuf, &DirstateEntry), | 476 res: (&HgPathBuf, &DirstateEntry), |
471 ) -> PyResult<Option<PyBytes>> { | 477 ) -> PyResult<Option<PyBytes>> { |
472 Ok(Some(PyBytes::new(py, res.0.as_ref()))) | 478 Ok(Some(PyBytes::new(py, res.0.as_ref()))) |