Mercurial > hg
diff rust/rhg/src/commands/status.rs @ 49894:678588b01af1
rhg: implement checkexec to support weird filesystems
In particular, some of our repos are stored on a fileserver that simulates
POSIX permissions poorly, in such a way that prevents the removal
of execute permission.
This causes rhg show a spurious unclean status, even though python
hg reports the repo as clean.
We fix this by making rhg implement the ~same checkexec logic
that python hg does.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Thu, 05 Jan 2023 17:15:03 +0000 |
parents | 37bc3edef76f |
children | 58074252db3c |
line wrap: on
line diff
--- a/rust/rhg/src/commands/status.rs Wed Jan 11 16:16:06 2023 +0000 +++ b/rust/rhg/src/commands/status.rs Thu Jan 05 17:15:03 2023 +0000 @@ -254,10 +254,10 @@ let mut dmap = repo.dirstate_map_mut()?; + let check_exec = hg::checkexec::check_exec(repo.working_directory_path()); + let options = StatusOptions { - // we're currently supporting file systems with exec flags only - // anyway - check_exec: true, + check_exec, list_clean: display_states.clean, list_unknown: display_states.unknown, list_ignored: display_states.ignored, @@ -312,6 +312,7 @@ unsure_is_modified( working_directory_vfs, store_vfs, + check_exec, &manifest, &to_check.path, ) @@ -554,6 +555,7 @@ fn unsure_is_modified( working_directory_vfs: hg::vfs::Vfs, store_vfs: hg::vfs::Vfs, + check_exec: bool, manifest: &Manifest, hg_path: &HgPath, ) -> Result<bool, HgError> { @@ -561,20 +563,32 @@ let fs_path = hg_path_to_path_buf(hg_path).expect("HgPath conversion"); let fs_metadata = vfs.symlink_metadata(&fs_path)?; let is_symlink = fs_metadata.file_type().is_symlink(); + + let entry = manifest + .find_by_path(hg_path)? + .expect("ambgious file not in p1"); + // TODO: Also account for `FALLBACK_SYMLINK` and `FALLBACK_EXEC` from the // dirstate let fs_flags = if is_symlink { Some(b'l') - } else if has_exec_bit(&fs_metadata) { + } else if check_exec && has_exec_bit(&fs_metadata) { Some(b'x') } else { None }; - let entry = manifest - .find_by_path(hg_path)? - .expect("ambgious file not in p1"); - if entry.flags != fs_flags { + let entry_flags = if check_exec { + entry.flags + } else { + if entry.flags == Some(b'x') { + None + } else { + entry.flags + } + }; + + if entry_flags != fs_flags { return Ok(true); } let filelog = hg::filelog::Filelog::open_vfs(&store_vfs, hg_path)?;