Mercurial > hg
comparison rust/hg-cpython/src/dirstate/dirstate_map.rs @ 47518:f6f25ab6bfc8
rust-dirstatemap: expand the wrapping code a bit
This is easier to read.
Differential Revision: https://phab.mercurial-scm.org/D10960
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 04 Jul 2021 19:42:03 +0200 |
parents | eaae39894312 |
children | abed645b8e96 |
comparison
equal
deleted
inserted
replaced
47517:28632eb3ca3e | 47518:f6f25ab6bfc8 |
---|---|
110 state: PyObject, | 110 state: PyObject, |
111 mode: PyObject, | 111 mode: PyObject, |
112 size: PyObject, | 112 size: PyObject, |
113 mtime: PyObject | 113 mtime: PyObject |
114 ) -> PyResult<PyObject> { | 114 ) -> PyResult<PyObject> { |
115 let f = f.extract::<PyBytes>(py)?; | |
116 let filename = HgPath::new(f.data(py)); | |
117 let oldstate = oldstate.extract::<PyBytes>(py)?.data(py)[0] | |
118 .try_into() | |
119 .map_err(|e: HgError| { | |
120 PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
121 })?; | |
122 let state = state.extract::<PyBytes>(py)?.data(py)[0] | |
123 .try_into() | |
124 .map_err(|e: HgError| { | |
125 PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
126 })?; | |
127 let mode = mode.extract(py)?; | |
128 let size = size.extract(py)?; | |
129 let mtime = mtime.extract(py)?; | |
130 let entry = DirstateEntry { | |
131 state: state, | |
132 mode: mode, | |
133 size: size, | |
134 mtime: mtime, | |
135 }; | |
115 self.inner(py).borrow_mut().add_file( | 136 self.inner(py).borrow_mut().add_file( |
116 HgPath::new(f.extract::<PyBytes>(py)?.data(py)), | 137 filename, |
117 oldstate.extract::<PyBytes>(py)?.data(py)[0] | 138 oldstate, |
118 .try_into() | 139 entry, |
119 .map_err(|e: HgError| { | |
120 PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
121 })?, | |
122 DirstateEntry { | |
123 state: state.extract::<PyBytes>(py)?.data(py)[0] | |
124 .try_into() | |
125 .map_err(|e: HgError| { | |
126 PyErr::new::<exc::ValueError, _>(py, e.to_string()) | |
127 })?, | |
128 mode: mode.extract(py)?, | |
129 size: size.extract(py)?, | |
130 mtime: mtime.extract(py)?, | |
131 }, | |
132 ).and(Ok(py.None())).or_else(|e: DirstateError| { | 140 ).and(Ok(py.None())).or_else(|e: DirstateError| { |
133 Err(PyErr::new::<exc::ValueError, _>(py, e.to_string())) | 141 Err(PyErr::new::<exc::ValueError, _>(py, e.to_string())) |
134 }) | 142 }) |
135 } | 143 } |
136 | 144 |