comparison rust/hg-core/src/dirstate/dirstate_map.rs @ 47093:787ff5d21bcd

dirstate-tree: Make Rust DirstateMap bindings go through a trait object This changeset starts a series that adds an experiment to make status faster by changing the dirstate (first only in memory and later also on disk) to be shaped as a tree matching the directory structure, instead of the current flat collection of entries. The status algorithm can then traverse this tree dirstate at the same time as it traverses the filesystem. We (Octobus) have made prototypes that show promising results but are prone to bitrot. We would like to start upstreaming some experimental Rust code that goes in this direction, but to avoid disrupting users it should only be enabled by some run-time opt-in while keeping the existing dirstate structure and status algorithm as-is. The `DirstateMap` type and `status` function look like the appropriate boundary. This adds a new trait that abstracts everything Python bindings need and makes those bindings go through a `dyn` trait object. Later we’ll have two implementations of this trait, and the same bindings can use either. Differential Revision: https://phab.mercurial-scm.org/D10362
author Simon Sapin <simon.sapin@octobus.net>
date Tue, 30 Mar 2021 14:15:23 +0200
parents 441024b279a6
children 5d62243c7732
comparison
equal deleted inserted replaced
47092:102a50746bc5 47093:787ff5d21bcd
287 /// emulate a Python lazy property, but it is ugly and unidiomatic. 287 /// emulate a Python lazy property, but it is ugly and unidiomatic.
288 /// TODO One day, rewriting this struct using the typestate might be a 288 /// TODO One day, rewriting this struct using the typestate might be a
289 /// good idea. 289 /// good idea.
290 pub fn set_all_dirs(&mut self) -> Result<(), DirstateMapError> { 290 pub fn set_all_dirs(&mut self) -> Result<(), DirstateMapError> {
291 if self.all_dirs.is_none() { 291 if self.all_dirs.is_none() {
292 self.all_dirs = 292 self.all_dirs = Some(DirsMultiset::from_dirstate(
293 Some(DirsMultiset::from_dirstate(&self.state_map, None)?); 293 self.state_map.iter(),
294 None,
295 )?);
294 } 296 }
295 Ok(()) 297 Ok(())
296 } 298 }
297 299
298 pub fn set_dirs(&mut self) -> Result<(), DirstateMapError> { 300 pub fn set_dirs(&mut self) -> Result<(), DirstateMapError> {