changeset 49112:a55934393078

rust-distatemap: remove `addfile` API All of its users have been migrated to the new API Differential Revision: https://phab.mercurial-scm.org/D12510
author Raphaël Gomès <rgomes@octobus.net>
date Wed, 23 Mar 2022 17:19:32 +0100
parents 8a17fc501eda
children 2e63040a333b
files rust/hg-core/src/dirstate_tree/dirstate_map.rs rust/hg-cpython/src/dirstate/dirstate_map.rs
diffstat 2 files changed, 0 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Wed Mar 23 17:16:10 2022 +0100
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs	Wed Mar 23 17:19:32 2022 +0100
@@ -727,49 +727,6 @@
         Ok(new)
     }
 
-    fn add_or_remove_file(
-        &mut self,
-        path: &HgPath,
-        old_state: Option<EntryState>,
-        new_entry: DirstateEntry,
-    ) -> Result<(), DirstateV2ParseError> {
-        let had_entry = old_state.is_some();
-        let was_tracked = old_state.map_or(false, |s| s.is_tracked());
-        let tracked_count_increment =
-            match (was_tracked, new_entry.state().is_tracked()) {
-                (false, true) => 1,
-                (true, false) => -1,
-                _ => 0,
-            };
-
-        let node = Self::get_or_insert_node(
-            self.on_disk,
-            &mut self.unreachable_bytes,
-            &mut self.root,
-            path,
-            WithBasename::to_cow_owned,
-            |ancestor| {
-                if !had_entry {
-                    ancestor.descendants_with_entry_count += 1;
-                }
-
-                // We can’t use `+= increment` because the counter is unsigned,
-                // and we want debug builds to detect accidental underflow
-                // through zero
-                match tracked_count_increment {
-                    1 => ancestor.tracked_descendants_count += 1,
-                    -1 => ancestor.tracked_descendants_count -= 1,
-                    _ => {}
-                }
-            },
-        )?;
-        if !had_entry {
-            self.nodes_with_entry_count += 1
-        }
-        node.data = NodeData::Entry(new_entry);
-        Ok(())
-    }
-
     /// It is the responsibility of the caller to know that there was an entry
     /// there before. Does not handle the removal of copy source
     fn set_untracked(
@@ -938,17 +895,6 @@
         })
     }
 
-    pub fn add_file(
-        &mut self,
-        filename: &HgPath,
-        entry: DirstateEntry,
-    ) -> Result<(), DirstateError> {
-        let old_state = self.get(filename)?.map(|e| e.state());
-        self.with_dmap_mut(|map| {
-            Ok(map.add_or_remove_file(filename, old_state, entry)?)
-        })
-    }
-
     pub fn set_tracked(
         &mut self,
         filename: &HgPath,
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Mar 23 17:16:10 2022 +0100
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs	Wed Mar 23 17:19:32 2022 +0100
@@ -118,20 +118,6 @@
         Ok(py.None())
     }
 
-    def addfile(
-        &self,
-        f: PyBytes,
-        item: DirstateItem,
-    ) -> PyResult<PyNone> {
-        let filename = HgPath::new(f.data(py));
-        let entry = item.get_entry(py);
-        self.inner(py)
-            .borrow_mut()
-            .add_file(filename, entry)
-            .map_err(|e |dirstate_error(py, e))?;
-        Ok(PyNone)
-    }
-
     def set_tracked(&self, f: PyObject) -> PyResult<PyBool> {
         let bytes = f.extract::<PyBytes>(py)?;
         let path = HgPath::new(bytes.data(py));