Mercurial > hg
changeset 52036:d7bc6e482033
rust-repo: add a method to set the current parents
This will be useful when we start writing an `hg update` fastpath.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 30 Sep 2024 17:46:52 +0200 |
parents | babfa9ddca0e |
children | 0ea323b7e3b1 |
files | rust/hg-core/src/repo.rs |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/hg-core/src/repo.rs Mon Sep 30 17:46:24 2024 +0200 +++ b/rust/hg-core/src/repo.rs Mon Sep 30 17:46:52 2024 +0200 @@ -803,6 +803,24 @@ .ok() .and_then(|c| c.node_from_rev(rev).copied()) } + + /// Change the current working directory parents cached in the repo. + /// + /// TODO + /// This does *not* do a lot of what it expected from a full `set_parents`: + /// - parents should probably be stored in the dirstate + /// - dirstate should have a "changing parents" context + /// - dirstate should return copies if out of a merge context to be + /// discarded within the repo context + /// See `setparents` in `context.py`. + pub fn manually_set_parents( + &self, + new_parents: DirstateParents, + ) -> Result<(), HgError> { + let mut parents = self.dirstate_parents.value.borrow_mut(); + *parents = Some(new_parents); + Ok(()) + } } /// Lazily-initialized component of `Repo` with interior mutability