Patchwork D12510: rust-distatemap: remove `addfile` API

login
register
mail settings
Submitter phabricator
Date April 12, 2022, 4:03 p.m.
Message ID <differential-rev-PHID-DREV-uh45hi2fbpkrk3xm3cyz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50858/
State New
Headers show

Comments

phabricator - April 12, 2022, 4:03 p.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  All of its users have been migrated to the new API

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12510

AFFECTED FILES
  rust/hg-core/src/dirstate_tree/dirstate_map.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -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));
diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
--- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs
@@ -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,