[Updated] [+ ] D11834: rust: Serializing a DirstateMap does not mutate it anymore
SimonSapin
phabricator at mercurial-scm.org
Mon Dec 6 10:03:42 UTC 2021
SimonSapin updated this revision to Diff 31316.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11834?vs=31263&id=31316
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11834/new/
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
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
@@ -553,7 +553,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)
}
To: SimonSapin, #hg-reviewers, Alphare
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211206/73774a87/attachment-0002.html>
More information about the Mercurial-patches
mailing list