##// END OF EJS Templates
rust-repo: move dirstate-v2 opening to a separate method...
Raphaël Gomès -
r51122:cbd4c923 stable
parent child Browse files
Show More
@@ -305,14 +305,31 b' impl Repo {'
305 305 }
306 306
307 307 fn new_dirstate_map(&self) -> Result<OwningDirstateMap, DirstateError> {
308 if self.has_dirstate_v2() {
309 self.read_docket_and_data_file()
310 } else {
308 311 let dirstate_file_contents = self.dirstate_file_contents()?;
309 312 if dirstate_file_contents.is_empty() {
310 313 self.dirstate_parents.set(DirstateParents::NULL);
311 if self.has_dirstate_v2() {
312 self.dirstate_data_file_uuid.set(None);
314 Ok(OwningDirstateMap::new_empty(Vec::new()))
315 } else {
316 let (map, parents) =
317 OwningDirstateMap::new_v1(dirstate_file_contents)?;
318 self.dirstate_parents.set(parents);
319 Ok(map)
320 }
321 }
313 322 }
314 Ok(OwningDirstateMap::new_empty(Vec::new()))
315 } else if self.has_dirstate_v2() {
323
324 fn read_docket_and_data_file(
325 &self,
326 ) -> Result<OwningDirstateMap, DirstateError> {
327 let dirstate_file_contents = self.dirstate_file_contents()?;
328 if dirstate_file_contents.is_empty() {
329 self.dirstate_parents.set(DirstateParents::NULL);
330 self.dirstate_data_file_uuid.set(None);
331 return Ok(OwningDirstateMap::new_empty(Vec::new()));
332 }
316 333 let docket = crate::dirstate_tree::on_disk::read_docket(
317 334 &dirstate_file_contents,
318 335 )?;
@@ -321,8 +338,7 b' impl Repo {'
321 338 .set(Some(docket.uuid.to_owned()));
322 339 let data_size = docket.data_size();
323 340 let metadata = docket.tree_metadata();
324 let mut map =
325 if crate::vfs::is_on_nfs_mount(docket.data_filename()) {
341 let mut map = if crate::vfs::is_on_nfs_mount(docket.data_filename()) {
326 342 // Don't mmap on NFS to prevent `SIGBUS` error on deletion
327 343 OwningDirstateMap::new_v2(
328 344 self.hg_vfs().read(docket.data_filename())?,
@@ -354,12 +370,6 b' impl Repo {'
354 370 map.with_dmap_mut(|m| m.set_write_mode(write_mode));
355 371
356 372 Ok(map)
357 } else {
358 let (map, parents) =
359 OwningDirstateMap::new_v1(dirstate_file_contents)?;
360 self.dirstate_parents.set(parents);
361 Ok(map)
362 }
363 373 }
364 374
365 375 pub fn dirstate_map(
General Comments 0
You need to be logged in to leave comments. Login now