Patchwork D11834: rust: Serializing a DirstateMap does not mutate it anymore

login
register
mail settings
Submitter phabricator
Date Dec. 2, 2021, 4:49 p.m.
Message ID <differential-rev-PHID-DREV-nco6asv2fl2apoy2vzlm-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50162/
State Superseded
Headers show

Comments

phabricator - Dec. 2, 2021, 4:49 p.m.
SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS




To: SimonSapin, #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
@@ -195,7 +195,7 @@ 
         p1: PyObject,
         p2: PyObject,
     ) -> PyResult<PyBytes> {
-        let mut inner = self.inner(py).borrow_mut();
+        let inner = self.inner(py).borrow();
         let parents = DirstateParents {
             p1: extract_node_id(py, &p1)?,
             p2: extract_node_id(py, &p2)?,
@@ -217,7 +217,7 @@ 
         &self,
         can_append: bool,
     ) -> PyResult<PyObject> {
-        let mut inner = self.inner(py).borrow_mut();
+        let inner = self.inner(py).borrow();
         let result = inner.pack_v2(can_append);
         match result {
             Ok((packed, tree_metadata, append)) => {
diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs b/rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs
@@ -549,7 +549,7 @@ 
 /// `dirstate_map.on_disk` (true), instead of written to a new data file
 /// (false).
 pub(super) fn write(
-    dirstate_map: &mut DirstateMap,
+    dirstate_map: &DirstateMap,
     can_append: bool,
 ) -> Result<(Vec<u8>, Vec<u8>, bool), DirstateError> {
     let append = can_append && dirstate_map.write_should_append();
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
@@ -909,10 +909,10 @@ 
 
     #[timed]
     pub fn pack_v1(
-        &mut self,
+        &self,
         parents: DirstateParents,
     ) -> Result<Vec<u8>, DirstateError> {
-        let map = self.get_map_mut();
+        let map = self.get_map();
         // Optizimation (to be measured?): pre-compute size to avoid `Vec`
         // reallocations
         let mut size = parents.as_bytes().len();
@@ -949,10 +949,10 @@ 
     /// (false).
     #[timed]
     pub fn pack_v2(
-        &mut self,
+        &self,
         can_append: bool,
     ) -> Result<(Vec<u8>, Vec<u8>, bool), DirstateError> {
-        let map = self.get_map_mut();
+        let map = self.get_map();
         on_disk::write(map, can_append)
     }