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