Show More
@@ -664,7 +664,7 b' if rustmod is not None:' | |||||
664 | new = True |
|
664 | new = True | |
665 | elif not entry.tracked: |
|
665 | elif not entry.tracked: | |
666 | entry.set_tracked() |
|
666 | entry.set_tracked() | |
667 |
self._rustmap.set_ |
|
667 | self._rustmap.set_dirstate_item(filename, entry) | |
668 | new = True |
|
668 | new = True | |
669 | else: |
|
669 | else: | |
670 | # XXX This is probably overkill for more case, but we need this to |
|
670 | # XXX This is probably overkill for more case, but we need this to | |
@@ -949,7 +949,7 b' if rustmod is not None:' | |||||
949 | """record that the current state of the file on disk is unknown""" |
|
949 | """record that the current state of the file on disk is unknown""" | |
950 | entry = self[filename] |
|
950 | entry = self[filename] | |
951 | entry.set_possibly_dirty() |
|
951 | entry.set_possibly_dirty() | |
952 |
self._rustmap.set_ |
|
952 | self._rustmap.set_dirstate_item(filename, entry) | |
953 |
|
953 | |||
954 | def set_clean(self, filename, mode, size, mtime): |
|
954 | def set_clean(self, filename, mode, size, mtime): | |
955 | """mark a file as back to a clean state""" |
|
955 | """mark a file as back to a clean state""" | |
@@ -957,9 +957,9 b' if rustmod is not None:' | |||||
957 | mtime = mtime & rangemask |
|
957 | mtime = mtime & rangemask | |
958 | size = size & rangemask |
|
958 | size = size & rangemask | |
959 | entry.set_clean(mode, size, mtime) |
|
959 | entry.set_clean(mode, size, mtime) | |
960 |
self._rustmap.set_ |
|
960 | self._rustmap.set_dirstate_item(filename, entry) | |
961 | self._rustmap.copymap().pop(filename, None) |
|
961 | self._rustmap.copymap().pop(filename, None) | |
962 |
|
962 | |||
963 | def __setitem__(self, key, value): |
|
963 | def __setitem__(self, key, value): | |
964 | assert isinstance(value, DirstateItem) |
|
964 | assert isinstance(value, DirstateItem) | |
965 |
self._rustmap.set_ |
|
965 | self._rustmap.set_dirstate_item(key, value) |
@@ -64,7 +64,7 b' impl DirstateMap {' | |||||
64 | self.other_parent_set = None; |
|
64 | self.other_parent_set = None; | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 |
pub fn set_ |
|
67 | pub fn set_entry(&mut self, filename: &HgPath, entry: DirstateEntry) { | |
68 | self.state_map.insert(filename.to_owned(), entry); |
|
68 | self.state_map.insert(filename.to_owned(), entry); | |
69 | } |
|
69 | } | |
70 |
|
70 |
@@ -758,7 +758,7 b" impl<'on_disk> super::dispatch::Dirstate" | |||||
758 | self.nodes_with_copy_source_count = 0; |
|
758 | self.nodes_with_copy_source_count = 0; | |
759 | } |
|
759 | } | |
760 |
|
760 | |||
761 |
fn set_ |
|
761 | fn set_entry(&mut self, filename: &HgPath, entry: DirstateEntry) { | |
762 | let node = |
|
762 | let node = | |
763 | self.get_or_insert(&filename).expect("no parse error in v1"); |
|
763 | self.get_or_insert(&filename).expect("no parse error in v1"); | |
764 | node.data = NodeData::Entry(entry); |
|
764 | node.data = NodeData::Entry(entry); |
@@ -37,7 +37,9 b' pub trait DirstateMapMethods {' | |||||
37 | /// Remove information about all files in this map |
|
37 | /// Remove information about all files in this map | |
38 | fn clear(&mut self); |
|
38 | fn clear(&mut self); | |
39 |
|
39 | |||
40 | fn set_v1(&mut self, filename: &HgPath, entry: DirstateEntry); |
|
40 | /// Add the given filename to the map if it is not already there, and | |
|
41 | /// associate the given entry with it. | |||
|
42 | fn set_entry(&mut self, filename: &HgPath, entry: DirstateEntry); | |||
41 |
|
43 | |||
42 | /// Add or change the information associated to a given file. |
|
44 | /// Add or change the information associated to a given file. | |
43 | /// |
|
45 | /// | |
@@ -319,8 +321,8 b' impl DirstateMapMethods for DirstateMap ' | |||||
319 | /// |
|
321 | /// | |
320 | /// XXX Is temporary during a refactor of V1 dirstate and will disappear |
|
322 | /// XXX Is temporary during a refactor of V1 dirstate and will disappear | |
321 | /// shortly. |
|
323 | /// shortly. | |
322 |
fn set_ |
|
324 | fn set_entry(&mut self, filename: &HgPath, entry: DirstateEntry) { | |
323 |
self.set_ |
|
325 | self.set_entry(&filename, entry) | |
324 | } |
|
326 | } | |
325 |
|
327 | |||
326 | fn add_file( |
|
328 | fn add_file( |
@@ -20,8 +20,8 b' impl DirstateMapMethods for OwningDirsta' | |||||
20 | self.get_mut().clear() |
|
20 | self.get_mut().clear() | |
21 | } |
|
21 | } | |
22 |
|
22 | |||
23 |
fn set_ |
|
23 | fn set_entry(&mut self, filename: &HgPath, entry: DirstateEntry) { | |
24 |
self.get_mut().set_ |
|
24 | self.get_mut().set_entry(filename, entry) | |
25 | } |
|
25 | } | |
26 |
|
26 | |||
27 | fn add_file( |
|
27 | fn add_file( |
@@ -129,18 +129,14 b' py_class!(pub class DirstateMap |py| {' | |||||
129 | } |
|
129 | } | |
130 | } |
|
130 | } | |
131 |
|
131 | |||
132 | def set_v1(&self, path: PyObject, item: PyObject) -> PyResult<PyObject> { |
|
132 | def set_dirstate_item( | |
|
133 | &self, | |||
|
134 | path: PyObject, | |||
|
135 | item: DirstateItem | |||
|
136 | ) -> PyResult<PyObject> { | |||
133 | let f = path.extract::<PyBytes>(py)?; |
|
137 | let f = path.extract::<PyBytes>(py)?; | |
134 | let filename = HgPath::new(f.data(py)); |
|
138 | let filename = HgPath::new(f.data(py)); | |
135 | let state = item.getattr(py, "state")?.extract::<PyBytes>(py)?; |
|
139 | self.inner(py).borrow_mut().set_entry(filename, item.get_entry(py)); | |
136 | let state = state.data(py)[0]; |
|
|||
137 | let entry = DirstateEntry::from_v1_data( |
|
|||
138 | state.try_into().expect("state is always valid"), |
|
|||
139 | item.getattr(py, "mode")?.extract(py)?, |
|
|||
140 | item.getattr(py, "size")?.extract(py)?, |
|
|||
141 | item.getattr(py, "mtime")?.extract(py)?, |
|
|||
142 | ); |
|
|||
143 | self.inner(py).borrow_mut().set_v1(filename, entry); |
|
|||
144 | Ok(py.None()) |
|
140 | Ok(py.None()) | |
145 | } |
|
141 | } | |
146 |
|
142 |
@@ -180,6 +180,10 b' impl DirstateItem {' | |||||
180 | Ok(DirstateItem::create_instance(py, Cell::new(entry))?.into_object()) |
|
180 | Ok(DirstateItem::create_instance(py, Cell::new(entry))?.into_object()) | |
181 | } |
|
181 | } | |
182 |
|
182 | |||
|
183 | pub fn get_entry(&self, py: Python<'_>) -> DirstateEntry { | |||
|
184 | self.entry(py).get() | |||
|
185 | } | |||
|
186 | ||||
183 | // TODO: Use https://doc.rust-lang.org/std/cell/struct.Cell.html#method.update instead when it’s stable |
|
187 | // TODO: Use https://doc.rust-lang.org/std/cell/struct.Cell.html#method.update instead when it’s stable | |
184 | pub fn update(&self, py: Python<'_>, f: impl FnOnce(&mut DirstateEntry)) { |
|
188 | pub fn update(&self, py: Python<'_>, f: impl FnOnce(&mut DirstateEntry)) { | |
185 | let mut entry = self.entry(py).get(); |
|
189 | let mut entry = self.entry(py).get(); |
General Comments 0
You need to be logged in to leave comments.
Login now