Mercurial > hg
comparison rust/hg-cpython/src/dirstate/dirstate_map.rs @ 48051:98c0408324e6
dirstate: Pass the final DirstateItem to _rustmap.addfile()
Now that the Python DirstateItem class wraps a Rust DirstateEntry value,
use that value directly instead of converting through v1 data + 5 booleans.
Also remove propogating the return value. None of the callers look at it,
and it is always None.
Differential Revision: https://phab.mercurial-scm.org/D11494
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 23 Sep 2021 18:29:40 +0200 |
parents | 2ac0e6b23222 |
children | cd13d3c2ad2e |
comparison
equal
deleted
inserted
replaced
48050:2ac0e6b23222 | 48051:98c0408324e6 |
---|---|
25 }, | 25 }, |
26 pybytes_deref::PyBytesDeref, | 26 pybytes_deref::PyBytesDeref, |
27 }; | 27 }; |
28 use hg::{ | 28 use hg::{ |
29 dirstate::parsers::Timestamp, | 29 dirstate::parsers::Timestamp, |
30 dirstate::MTIME_UNSET, | |
31 dirstate::SIZE_NON_NORMAL, | |
32 dirstate_tree::dirstate_map::DirstateMap as TreeDirstateMap, | 30 dirstate_tree::dirstate_map::DirstateMap as TreeDirstateMap, |
33 dirstate_tree::dispatch::DirstateMapMethods, | 31 dirstate_tree::dispatch::DirstateMapMethods, |
34 dirstate_tree::on_disk::DirstateV2ParseError, | 32 dirstate_tree::on_disk::DirstateV2ParseError, |
35 dirstate_tree::owning::OwningDirstateMap, | 33 dirstate_tree::owning::OwningDirstateMap, |
36 revlog::Node, | 34 revlog::Node, |
143 Ok(py.None()) | 141 Ok(py.None()) |
144 } | 142 } |
145 | 143 |
146 def addfile( | 144 def addfile( |
147 &self, | 145 &self, |
148 f: PyObject, | 146 f: PyBytes, |
149 mode: PyObject, | 147 item: DirstateItem, |
150 size: PyObject, | 148 ) -> PyResult<PyNone> { |
151 mtime: PyObject, | |
152 added: PyObject, | |
153 merged: PyObject, | |
154 from_p2: PyObject, | |
155 possibly_dirty: PyObject, | |
156 ) -> PyResult<PyObject> { | |
157 let f = f.extract::<PyBytes>(py)?; | |
158 let filename = HgPath::new(f.data(py)); | 149 let filename = HgPath::new(f.data(py)); |
159 let mode = if mode.is_none(py) { | 150 let entry = item.get_entry(py); |
160 // fallback default value | 151 self.inner(py) |
161 0 | 152 .borrow_mut() |
162 } else { | 153 .add_file(filename, entry) |
163 mode.extract(py)? | 154 .map_err(|e |dirstate_error(py, e))?; |
164 }; | 155 Ok(PyNone) |
165 let size = if size.is_none(py) { | |
166 // fallback default value | |
167 SIZE_NON_NORMAL | |
168 } else { | |
169 size.extract(py)? | |
170 }; | |
171 let mtime = if mtime.is_none(py) { | |
172 // fallback default value | |
173 MTIME_UNSET | |
174 } else { | |
175 mtime.extract(py)? | |
176 }; | |
177 let entry = DirstateEntry::new_for_add_file(mode, size, mtime); | |
178 let added = added.extract::<PyBool>(py)?.is_true(); | |
179 let merged = merged.extract::<PyBool>(py)?.is_true(); | |
180 let from_p2 = from_p2.extract::<PyBool>(py)?.is_true(); | |
181 let possibly_dirty = possibly_dirty.extract::<PyBool>(py)?.is_true(); | |
182 self.inner(py).borrow_mut().add_file( | |
183 filename, | |
184 entry, | |
185 added, | |
186 merged, | |
187 from_p2, | |
188 possibly_dirty | |
189 ).and(Ok(py.None())).or_else(|e: DirstateError| { | |
190 Err(PyErr::new::<exc::ValueError, _>(py, e.to_string())) | |
191 }) | |
192 } | 156 } |
193 | 157 |
194 def removefile( | 158 def removefile( |
195 &self, | 159 &self, |
196 f: PyObject, | 160 f: PyObject, |