Mercurial > hg
comparison rust/hg-core/src/repo.rs @ 52302:db065b33fa56
rust-dirstate: merge `dirstate_tree` module into `dirstate`
The historical reasonning for `dirstate_tree` existing in the first place is
that a new approach was needed for the tree-like dirstate and it was easier
to start somewhat fresh. Now that the former dirstate is (long) gone, we
can merge those two modules to avoid the confusion that even the module
creators sometimes get.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 04 Nov 2024 11:00:58 +0100 |
parents | a3fa37bdb7ec |
children | 79e8118cd846 |
comparison
equal
deleted
inserted
replaced
52301:7ffc71552662 | 52302:db065b33fa56 |
---|---|
1 use crate::config::{Config, ConfigError, ConfigParseError}; | 1 use crate::config::{Config, ConfigError, ConfigParseError}; |
2 use crate::dirstate::dirstate_map::{DirstateIdentity, DirstateMapWriteMode}; | |
3 use crate::dirstate::on_disk::Docket as DirstateDocket; | |
4 use crate::dirstate::owning::OwningDirstateMap; | |
2 use crate::dirstate::DirstateParents; | 5 use crate::dirstate::DirstateParents; |
3 use crate::dirstate_tree::dirstate_map::{ | |
4 DirstateIdentity, DirstateMapWriteMode, | |
5 }; | |
6 use crate::dirstate_tree::on_disk::Docket as DirstateDocket; | |
7 use crate::dirstate_tree::owning::OwningDirstateMap; | |
8 use crate::errors::HgResultExt; | 6 use crate::errors::HgResultExt; |
9 use crate::errors::{HgError, IoResultExt}; | 7 use crate::errors::{HgError, IoResultExt}; |
10 use crate::lock::{try_with_lock_no_wait, LockError}; | 8 use crate::lock::{try_with_lock_no_wait, LockError}; |
11 use crate::requirements::DIRSTATE_TRACKED_HINT_V1; | 9 use crate::requirements::DIRSTATE_TRACKED_HINT_V1; |
12 use crate::revlog::changelog::Changelog; | 10 use crate::revlog::changelog::Changelog; |
319 fn read_dirstate_parents(&self) -> Result<DirstateParents, HgError> { | 317 fn read_dirstate_parents(&self) -> Result<DirstateParents, HgError> { |
320 let dirstate = self.dirstate_file_contents()?; | 318 let dirstate = self.dirstate_file_contents()?; |
321 let parents = if dirstate.is_empty() { | 319 let parents = if dirstate.is_empty() { |
322 DirstateParents::NULL | 320 DirstateParents::NULL |
323 } else if self.use_dirstate_v2() { | 321 } else if self.use_dirstate_v2() { |
324 let docket_res = | 322 let docket_res = crate::dirstate::on_disk::read_docket(&dirstate); |
325 crate::dirstate_tree::on_disk::read_docket(&dirstate); | |
326 match docket_res { | 323 match docket_res { |
327 Ok(docket) => docket.parents(), | 324 Ok(docket) => docket.parents(), |
328 Err(_) => { | 325 Err(_) => { |
329 log::info!( | 326 log::info!( |
330 "Parsing dirstate docket failed, \ | 327 "Parsing dirstate docket failed, \ |
359 let identity = self.dirstate_identity()?; | 356 let identity = self.dirstate_identity()?; |
360 let dirstate = self.dirstate_file_contents()?; | 357 let dirstate = self.dirstate_file_contents()?; |
361 if dirstate.is_empty() { | 358 if dirstate.is_empty() { |
362 Ok((identity, None, 0)) | 359 Ok((identity, None, 0)) |
363 } else { | 360 } else { |
364 let docket_res = | 361 let docket_res = crate::dirstate::on_disk::read_docket(&dirstate); |
365 crate::dirstate_tree::on_disk::read_docket(&dirstate); | |
366 match docket_res { | 362 match docket_res { |
367 Ok(docket) => { | 363 Ok(docket) => { |
368 self.dirstate_parents.set(docket.parents()); | 364 self.dirstate_parents.set(docket.parents()); |
369 Ok(( | 365 Ok(( |
370 identity, | 366 identity, |
462 let dirstate_file_contents = self.dirstate_file_contents()?; | 458 let dirstate_file_contents = self.dirstate_file_contents()?; |
463 let identity = self.dirstate_identity()?; | 459 let identity = self.dirstate_identity()?; |
464 if dirstate_file_contents.is_empty() { | 460 if dirstate_file_contents.is_empty() { |
465 return Ok(OwningDirstateMap::new_empty(Vec::new(), identity)); | 461 return Ok(OwningDirstateMap::new_empty(Vec::new(), identity)); |
466 } | 462 } |
467 let docket = crate::dirstate_tree::on_disk::read_docket( | 463 let docket = |
468 &dirstate_file_contents, | 464 crate::dirstate::on_disk::read_docket(&dirstate_file_contents)?; |
469 )?; | |
470 debug_wait_for_file_or_print( | 465 debug_wait_for_file_or_print( |
471 self.config(), | 466 self.config(), |
472 "dirstate.post-docket-read-file", | 467 "dirstate.post-docket-read-file", |
473 ); | 468 ); |
474 self.dirstate_parents.set(docket.parents()); | 469 self.dirstate_parents.set(docket.parents()); |