Mercurial > hg
comparison rust/hg-cpython/src/dirstate/dirstate_map.rs @ 47682:78f7f0d490ee
dirstate-v2: Move fixed-size tree metadata into the docket file
Before this changeset, the dirstate-v2 data file contained not only nodes
and paths that may be reused when appending to an existing file,
but also some fixed-size metadata that applies to the entire tree
and was added at the end of the data file for every append.
This moves that metadata into the docket file, so that repeated "append"
operations without meaningful changes don’t actually need to grow any file.
Differential Revision: https://phab.mercurial-scm.org/D11098
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Thu, 15 Jul 2021 23:02:17 +0200 |
parents | 065e61628980 |
children | 284a20269a97 |
comparison
equal
deleted
inserted
replaced
47681:d94118365ec5 | 47682:78f7f0d490ee |
---|---|
82 /// Returns a DirstateMap | 82 /// Returns a DirstateMap |
83 @staticmethod | 83 @staticmethod |
84 def new_v2( | 84 def new_v2( |
85 on_disk: PyBytes, | 85 on_disk: PyBytes, |
86 data_size: usize, | 86 data_size: usize, |
87 tree_metadata: PyBytes, | |
87 ) -> PyResult<PyObject> { | 88 ) -> PyResult<PyObject> { |
88 let dirstate_error = |e: DirstateError| { | 89 let dirstate_error = |e: DirstateError| { |
89 PyErr::new::<exc::OSError, _>(py, format!("Dirstate error: {:?}", e)) | 90 PyErr::new::<exc::OSError, _>(py, format!("Dirstate error: {:?}", e)) |
90 }; | 91 }; |
91 let inner = OwningDirstateMap::new_v2(py, on_disk, data_size) | 92 let inner = OwningDirstateMap::new_v2( |
92 .map_err(dirstate_error)?; | 93 py, on_disk, data_size, tree_metadata, |
94 ).map_err(dirstate_error)?; | |
93 let map = Self::create_instance(py, Box::new(inner))?; | 95 let map = Self::create_instance(py, Box::new(inner))?; |
94 Ok(map.into_object()) | 96 Ok(map.into_object()) |
95 } | 97 } |
96 | 98 |
97 def clear(&self) -> PyResult<PyObject> { | 99 def clear(&self) -> PyResult<PyObject> { |
351 let now = Timestamp(now.extract(py)?); | 353 let now = Timestamp(now.extract(py)?); |
352 | 354 |
353 let mut inner = self.inner(py).borrow_mut(); | 355 let mut inner = self.inner(py).borrow_mut(); |
354 let result = inner.pack_v2(now, can_append); | 356 let result = inner.pack_v2(now, can_append); |
355 match result { | 357 match result { |
356 Ok((packed, append)) => { | 358 Ok((packed, tree_metadata, append)) => { |
357 let packed = PyBytes::new(py, &packed); | 359 let packed = PyBytes::new(py, &packed); |
358 Ok((packed, append).to_py_object(py).into_object()) | 360 let tree_metadata = PyBytes::new(py, &tree_metadata); |
361 let tuple = (packed, tree_metadata, append); | |
362 Ok(tuple.to_py_object(py).into_object()) | |
359 }, | 363 }, |
360 Err(_) => Err(PyErr::new::<exc::OSError, _>( | 364 Err(_) => Err(PyErr::new::<exc::OSError, _>( |
361 py, | 365 py, |
362 "Dirstate error".to_string(), | 366 "Dirstate error".to_string(), |
363 )), | 367 )), |