477 .expect("ambgious file not in p1"); |
477 .expect("ambgious file not in p1"); |
478 if entry.flags != fs_flags { |
478 if entry.flags != fs_flags { |
479 return Ok(true); |
479 return Ok(true); |
480 } |
480 } |
481 let filelog = repo.filelog(hg_path)?; |
481 let filelog = repo.filelog(hg_path)?; |
|
482 let fs_len = fs_metadata.len(); |
|
483 // TODO: check `fs_len` here like below, but based on |
|
484 // `RevlogEntry::uncompressed_len` without decompressing the full filelog |
|
485 // contents where possible. This is only valid if the revlog data does not |
|
486 // contain metadata. See how Python’s `revlog.rawsize` calls |
|
487 // `storageutil.filerevisioncopied`. |
|
488 // (Maybe also check for content-modifying flags? See `revlog.size`.) |
482 let filelog_entry = |
489 let filelog_entry = |
483 filelog.data_for_node(entry.node_id()?).map_err(|_| { |
490 filelog.data_for_node(entry.node_id()?).map_err(|_| { |
484 HgError::corrupted("filelog missing node from manifest") |
491 HgError::corrupted("filelog missing node from manifest") |
485 })?; |
492 })?; |
486 let contents_in_p1 = filelog_entry.data()?; |
493 let contents_in_p1 = filelog_entry.data()?; |
|
494 if contents_in_p1.len() as u64 != fs_len { |
|
495 // No need to read the file contents: |
|
496 // it cannot be equal if it has a different length. |
|
497 return Ok(true); |
|
498 } |
487 |
499 |
488 let fs_contents = if is_symlink { |
500 let fs_contents = if is_symlink { |
489 get_bytes_from_os_string(vfs.read_link(fs_path)?.into_os_string()) |
501 get_bytes_from_os_string(vfs.read_link(fs_path)?.into_os_string()) |
490 } else { |
502 } else { |
491 vfs.read(fs_path)? |
503 vfs.read(fs_path)? |