status: treat symlinks as regular files when unsupported

Summary: Tweak Rust status code to explicitly treat symlinks as regular files if the VFS doesn't support symlinks. This fixes weirdness where they were previously considered "untrackable" and wouldn't show up at all in "hg status".

Reviewed By: sggutier, zzl0

Differential Revision: D44521987

fbshipit-source-id: 8944ab115635268c997e5cb443d870b71c353f83
This commit is contained in:
Muir Manders 2023-03-29 17:02:41 -07:00 committed by Facebook GitHub Bot
parent 181790e684
commit 3215b15fd5
2 changed files with 13 additions and 1 deletions

View File

@ -53,7 +53,13 @@ impl Metadata {
}
pub fn is_file(&self, vfs: &VFS) -> bool {
!self.is_symlink(vfs) && self.flags.intersects(MetadataFlags::IS_REGULAR)
if vfs.supports_symlinks() {
self.flags.intersects(MetadataFlags::IS_REGULAR)
} else {
// If symlinks aren't supported, treat symlinks as regular files.
self.flags
.intersects(MetadataFlags::IS_REGULAR | MetadataFlags::IS_SYMLINK)
}
}
pub fn len(&self) -> Option<u64> {

View File

@ -301,3 +301,9 @@ Issue995: hg copy -A incorrectly handles symbolic links
$ hg mv -A dirlink newdir/dirlink
$ cd ..
Don't treat symlinks as untrackable if symlinks aren't supported.
$ newclientrepo
$ ln -s foo bar
$ SL_DEBUG_DISABLE_SYMLINKS=1 hg status
? bar