##// END OF EJS Templates
rust-distatemap: remove `addfile` API...
Raphaël Gomès -
r50003:a5593439 default
parent child Browse files
Show More
@@ -727,49 +727,6 b" impl<'on_disk> DirstateMap<'on_disk> {"
727 727 Ok(new)
728 728 }
729 729
730 fn add_or_remove_file(
731 &mut self,
732 path: &HgPath,
733 old_state: Option<EntryState>,
734 new_entry: DirstateEntry,
735 ) -> Result<(), DirstateV2ParseError> {
736 let had_entry = old_state.is_some();
737 let was_tracked = old_state.map_or(false, |s| s.is_tracked());
738 let tracked_count_increment =
739 match (was_tracked, new_entry.state().is_tracked()) {
740 (false, true) => 1,
741 (true, false) => -1,
742 _ => 0,
743 };
744
745 let node = Self::get_or_insert_node(
746 self.on_disk,
747 &mut self.unreachable_bytes,
748 &mut self.root,
749 path,
750 WithBasename::to_cow_owned,
751 |ancestor| {
752 if !had_entry {
753 ancestor.descendants_with_entry_count += 1;
754 }
755
756 // We can’t use `+= increment` because the counter is unsigned,
757 // and we want debug builds to detect accidental underflow
758 // through zero
759 match tracked_count_increment {
760 1 => ancestor.tracked_descendants_count += 1,
761 -1 => ancestor.tracked_descendants_count -= 1,
762 _ => {}
763 }
764 },
765 )?;
766 if !had_entry {
767 self.nodes_with_entry_count += 1
768 }
769 node.data = NodeData::Entry(new_entry);
770 Ok(())
771 }
772
773 730 /// It is the responsibility of the caller to know that there was an entry
774 731 /// there before. Does not handle the removal of copy source
775 732 fn set_untracked(
@@ -938,17 +895,6 b' impl OwningDirstateMap {'
938 895 })
939 896 }
940 897
941 pub fn add_file(
942 &mut self,
943 filename: &HgPath,
944 entry: DirstateEntry,
945 ) -> Result<(), DirstateError> {
946 let old_state = self.get(filename)?.map(|e| e.state());
947 self.with_dmap_mut(|map| {
948 Ok(map.add_or_remove_file(filename, old_state, entry)?)
949 })
950 }
951
952 898 pub fn set_tracked(
953 899 &mut self,
954 900 filename: &HgPath,
@@ -118,20 +118,6 b' py_class!(pub class DirstateMap |py| {'
118 118 Ok(py.None())
119 119 }
120 120
121 def addfile(
122 &self,
123 f: PyBytes,
124 item: DirstateItem,
125 ) -> PyResult<PyNone> {
126 let filename = HgPath::new(f.data(py));
127 let entry = item.get_entry(py);
128 self.inner(py)
129 .borrow_mut()
130 .add_file(filename, entry)
131 .map_err(|e |dirstate_error(py, e))?;
132 Ok(PyNone)
133 }
134
135 121 def set_tracked(&self, f: PyObject) -> PyResult<PyBool> {
136 122 let bytes = f.extract::<PyBytes>(py)?;
137 123 let path = HgPath::new(bytes.data(py));
General Comments 0
You need to be logged in to leave comments. Login now