Show More
@@ -772,6 +772,32 b" impl<'on_disk> DirstateMap<'on_disk> {" | |||||
772 | Ok(()) |
|
772 | Ok(()) | |
773 | } |
|
773 | } | |
774 |
|
774 | |||
|
775 | /// It is the responsibility of the caller to know that there was an entry | |||
|
776 | /// there before. Does not handle the removal of copy source | |||
|
777 | fn set_untracked( | |||
|
778 | &mut self, | |||
|
779 | filename: &HgPath, | |||
|
780 | old_entry: DirstateEntry, | |||
|
781 | ) -> Result<(), DirstateV2ParseError> { | |||
|
782 | let node = Self::get_or_insert_node( | |||
|
783 | self.on_disk, | |||
|
784 | &mut self.unreachable_bytes, | |||
|
785 | &mut self.root, | |||
|
786 | filename, | |||
|
787 | WithBasename::to_cow_owned, | |||
|
788 | |ancestor| { | |||
|
789 | ancestor.tracked_descendants_count = ancestor | |||
|
790 | .tracked_descendants_count | |||
|
791 | .checked_sub(1) | |||
|
792 | .expect("tracked_descendants_count should be >= 0"); | |||
|
793 | }, | |||
|
794 | )?; | |||
|
795 | let mut new_entry = old_entry.clone(); | |||
|
796 | new_entry.set_untracked(); | |||
|
797 | node.data = NodeData::Entry(new_entry); | |||
|
798 | Ok(()) | |||
|
799 | } | |||
|
800 | ||||
775 | fn set_clean( |
|
801 | fn set_clean( | |
776 | &mut self, |
|
802 | &mut self, | |
777 | filename: &HgPath, |
|
803 | filename: &HgPath, | |
@@ -933,6 +959,39 b' impl OwningDirstateMap {' | |||||
933 | self.with_dmap_mut(|map| map.set_tracked(filename, old_entry_opt)) |
|
959 | self.with_dmap_mut(|map| map.set_tracked(filename, old_entry_opt)) | |
934 | } |
|
960 | } | |
935 |
|
961 | |||
|
962 | pub fn set_untracked( | |||
|
963 | &mut self, | |||
|
964 | filename: &HgPath, | |||
|
965 | ) -> Result<bool, DirstateError> { | |||
|
966 | let old_entry_opt = self.get(filename)?; | |||
|
967 | match old_entry_opt { | |||
|
968 | None => Ok(false), | |||
|
969 | Some(old_entry) => { | |||
|
970 | if !old_entry.tracked() { | |||
|
971 | // `DirstateMap::set_untracked` is not a noop if | |||
|
972 | // already not tracked as it will decrement the | |||
|
973 | // tracked counters while going down. | |||
|
974 | return Ok(true); | |||
|
975 | } | |||
|
976 | if old_entry.added() { | |||
|
977 | // Untracking an "added" entry will just result in a | |||
|
978 | // worthless entry (and other parts of the code will | |||
|
979 | // complain about it), just drop it entirely. | |||
|
980 | self.drop_entry_and_copy_source(filename)?; | |||
|
981 | return Ok(true); | |||
|
982 | } | |||
|
983 | if !old_entry.p2_info() { | |||
|
984 | self.copy_map_remove(filename)?; | |||
|
985 | } | |||
|
986 | ||||
|
987 | self.with_dmap_mut(|map| { | |||
|
988 | map.set_untracked(filename, old_entry)?; | |||
|
989 | Ok(true) | |||
|
990 | }) | |||
|
991 | } | |||
|
992 | } | |||
|
993 | } | |||
|
994 | ||||
936 | pub fn set_clean( |
|
995 | pub fn set_clean( | |
937 | &mut self, |
|
996 | &mut self, | |
938 | filename: &HgPath, |
|
997 | filename: &HgPath, |
@@ -142,6 +142,16 b' py_class!(pub class DirstateMap |py| {' | |||||
142 | Ok(was_tracked.to_py_object(py)) |
|
142 | Ok(was_tracked.to_py_object(py)) | |
143 | } |
|
143 | } | |
144 |
|
144 | |||
|
145 | def set_untracked(&self, f: PyObject) -> PyResult<PyBool> { | |||
|
146 | let bytes = f.extract::<PyBytes>(py)?; | |||
|
147 | let path = HgPath::new(bytes.data(py)); | |||
|
148 | let res = self.inner(py).borrow_mut().set_untracked(path); | |||
|
149 | let was_tracked = res.or_else(|_| { | |||
|
150 | Err(PyErr::new::<exc::OSError, _>(py, "Dirstate error".to_string())) | |||
|
151 | })?; | |||
|
152 | Ok(was_tracked.to_py_object(py)) | |||
|
153 | } | |||
|
154 | ||||
145 | def set_clean( |
|
155 | def set_clean( | |
146 | &self, |
|
156 | &self, | |
147 | f: PyObject, |
|
157 | f: PyObject, |
General Comments 0
You need to be logged in to leave comments.
Login now