comparison rust/hg-core/src/repo.rs @ 52043:e1fe336c007a

rust-repo: don't use on-disk dirstate parents in v1 This mistake was not causing any problems yet since we were never updating parents from Rust code. This is about to change, so let's fix it.
author Rapha?l Gom?s <rgomes@octobus.net>
date Wed, 02 Oct 2024 13:36:51 +0200
parents 28a0eb21ff04
children a8cf6a852f11
comparison
equal deleted inserted replaced
52042:28a0eb21ff04 52043:e1fe336c007a
448 448
449 fn new_dirstate_map_v1(&self) -> Result<OwningDirstateMap, DirstateError> { 449 fn new_dirstate_map_v1(&self) -> Result<OwningDirstateMap, DirstateError> {
450 debug_wait_for_file_or_print(self.config(), "dirstate.pre-read-file"); 450 debug_wait_for_file_or_print(self.config(), "dirstate.pre-read-file");
451 let identity = self.dirstate_identity()?; 451 let identity = self.dirstate_identity()?;
452 let dirstate_file_contents = self.dirstate_file_contents()?; 452 let dirstate_file_contents = self.dirstate_file_contents()?;
453 let parents = self.dirstate_parents()?;
453 if dirstate_file_contents.is_empty() { 454 if dirstate_file_contents.is_empty() {
454 self.dirstate_parents.set(DirstateParents::NULL); 455 self.dirstate_parents.set(parents);
455 Ok(OwningDirstateMap::new_empty(Vec::new(), identity)) 456 Ok(OwningDirstateMap::new_empty(Vec::new(), identity))
456 } else { 457 } else {
457 let (map, parents) = 458 // Ignore the dirstate on-disk parents, they may have been set in
459 // the repo before
460 let (map, _) =
458 OwningDirstateMap::new_v1(dirstate_file_contents, identity)?; 461 OwningDirstateMap::new_v1(dirstate_file_contents, identity)?;
459 self.dirstate_parents.set(parents); 462 self.dirstate_parents.set(parents);
460 Ok(map) 463 Ok(map)
461 } 464 }
462 } 465 }