Show More
@@ -305,61 +305,71 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 { | |
|
311 | let dirstate_file_contents = self.dirstate_file_contents()?; | |
|
312 | if dirstate_file_contents.is_empty() { | |
|
313 | self.dirstate_parents.set(DirstateParents::NULL); | |
|
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 | } | |
|
322 | } | |
|
323 | ||
|
324 | fn read_docket_and_data_file( | |
|
325 | &self, | |
|
326 | ) -> Result<OwningDirstateMap, DirstateError> { | |
|
308 | 327 | let dirstate_file_contents = self.dirstate_file_contents()?; |
|
309 | 328 | if dirstate_file_contents.is_empty() { |
|
310 | 329 | self.dirstate_parents.set(DirstateParents::NULL); |
|
311 |
|
|
|
312 | self.dirstate_data_file_uuid.set(None); | |
|
313 |
|
|
|
314 | Ok(OwningDirstateMap::new_empty(Vec::new())) | |
|
315 | } else if self.has_dirstate_v2() { | |
|
316 | let docket = crate::dirstate_tree::on_disk::read_docket( | |
|
317 | &dirstate_file_contents, | |
|
318 | )?; | |
|
319 | self.dirstate_parents.set(docket.parents()); | |
|
320 | self.dirstate_data_file_uuid | |
|
321 | .set(Some(docket.uuid.to_owned())); | |
|
322 | let data_size = docket.data_size(); | |
|
323 | let metadata = docket.tree_metadata(); | |
|
324 | let mut map = | |
|
325 |
|
|
|
326 | // Don't mmap on NFS to prevent `SIGBUS` error on deletion | |
|
327 | OwningDirstateMap::new_v2( | |
|
328 | self.hg_vfs().read(docket.data_filename())?, | |
|
329 | data_size, | |
|
330 | metadata, | |
|
331 | ) | |
|
332 | } else if let Some(data_mmap) = self | |
|
333 | .hg_vfs() | |
|
334 | .mmap_open(docket.data_filename()) | |
|
335 | .io_not_found_as_none()? | |
|
336 | { | |
|
337 | OwningDirstateMap::new_v2(data_mmap, data_size, metadata) | |
|
338 | } else { | |
|
339 | OwningDirstateMap::new_v2(Vec::new(), data_size, metadata) | |
|
340 | }?; | |
|
330 | self.dirstate_data_file_uuid.set(None); | |
|
331 | return Ok(OwningDirstateMap::new_empty(Vec::new())); | |
|
332 | } | |
|
333 | let docket = crate::dirstate_tree::on_disk::read_docket( | |
|
334 | &dirstate_file_contents, | |
|
335 | )?; | |
|
336 | self.dirstate_parents.set(docket.parents()); | |
|
337 | self.dirstate_data_file_uuid | |
|
338 | .set(Some(docket.uuid.to_owned())); | |
|
339 | let data_size = docket.data_size(); | |
|
340 | let metadata = docket.tree_metadata(); | |
|
341 | let mut map = if crate::vfs::is_on_nfs_mount(docket.data_filename()) { | |
|
342 | // Don't mmap on NFS to prevent `SIGBUS` error on deletion | |
|
343 | OwningDirstateMap::new_v2( | |
|
344 | self.hg_vfs().read(docket.data_filename())?, | |
|
345 | data_size, | |
|
346 | metadata, | |
|
347 | ) | |
|
348 | } else if let Some(data_mmap) = self | |
|
349 | .hg_vfs() | |
|
350 | .mmap_open(docket.data_filename()) | |
|
351 | .io_not_found_as_none()? | |
|
352 | { | |
|
353 | OwningDirstateMap::new_v2(data_mmap, data_size, metadata) | |
|
354 | } else { | |
|
355 | OwningDirstateMap::new_v2(Vec::new(), data_size, metadata) | |
|
356 | }?; | |
|
341 | 357 | |
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
|
347 |
|
|
|
348 |
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
|
358 | let write_mode_config = self | |
|
359 | .config() | |
|
360 | .get_str(b"devel", b"dirstate.v2.data_update_mode") | |
|
361 | .unwrap_or(Some("auto")) | |
|
362 | .unwrap_or("auto"); // don't bother for devel options | |
|
363 | let write_mode = match write_mode_config { | |
|
364 | "auto" => DirstateMapWriteMode::Auto, | |
|
365 | "force-new" => DirstateMapWriteMode::ForceNewDataFile, | |
|
366 | "force-append" => DirstateMapWriteMode::ForceAppend, | |
|
367 | _ => DirstateMapWriteMode::Auto, | |
|
368 | }; | |
|
353 | 369 | |
|
354 |
|
|
|
370 | map.with_dmap_mut(|m| m.set_write_mode(write_mode)); | |
|
355 | 371 | |
|
356 |
|
|
|
357 | } else { | |
|
358 | let (map, parents) = | |
|
359 | OwningDirstateMap::new_v1(dirstate_file_contents)?; | |
|
360 | self.dirstate_parents.set(parents); | |
|
361 | Ok(map) | |
|
362 | } | |
|
372 | Ok(map) | |
|
363 | 373 | } |
|
364 | 374 | |
|
365 | 375 | pub fn dirstate_map( |
General Comments 0
You need to be logged in to leave comments.
Login now