mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
workingcopy: filter directories from watchman results
Summary: I don't think we need directory results from watchman, and in particular they were triggering use of the GitIgnorematcher because we were stupidly considering them as untracked files. Reviewed By: quark-zju Differential Revision: D45378855 fbshipit-source-id: c3dce4212801749ac25cc4f7ccd5c86cf8d8ee76
This commit is contained in:
parent
b778766fe6
commit
a3ed9e5a82
@ -30,8 +30,9 @@ bitflags! {
|
||||
const IS_SYMLINK = 1 << 0;
|
||||
const IS_EXEC = 1 << 1;
|
||||
const IS_REGULAR = 1 << 2;
|
||||
const HAS_MTIME = 1 << 3;
|
||||
const HAS_SIZE = 1 << 4;
|
||||
const IS_DIR = 1 << 3;
|
||||
const HAS_MTIME = 1 << 4;
|
||||
const HAS_SIZE = 1 << 5;
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,12 +79,17 @@ impl Metadata {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_dir(&self) -> bool {
|
||||
self.flags.intersects(MetadataFlags::IS_DIR)
|
||||
}
|
||||
|
||||
pub fn from_stat(mode: u32, size: u64, mtime: i64) -> Self {
|
||||
// Watchman sends mode_t even on Windows where they aren't fully
|
||||
// reflected in libc. Let's just hardcode the values we need.
|
||||
const S_IFLNK: u32 = 0o120000;
|
||||
const S_IFMT: u32 = 0o170000;
|
||||
const S_IFREG: u32 = 0o100000;
|
||||
const S_IFDIR: u32 = 0o040000;
|
||||
|
||||
let mut flags = MetadataFlags::HAS_SIZE | MetadataFlags::HAS_MTIME;
|
||||
|
||||
@ -97,6 +103,10 @@ impl Metadata {
|
||||
flags |= MetadataFlags::IS_REGULAR;
|
||||
}
|
||||
|
||||
if mode & S_IFMT == S_IFDIR {
|
||||
flags |= MetadataFlags::IS_DIR;
|
||||
}
|
||||
|
||||
Self {
|
||||
flags,
|
||||
size,
|
||||
@ -151,6 +161,8 @@ impl From<std::fs::Metadata> for Metadata {
|
||||
if m.permissions().mode() & 0o111 != 0 {
|
||||
flags |= MetadataFlags::IS_EXEC;
|
||||
}
|
||||
} else if m.is_dir() {
|
||||
flags |= MetadataFlags::IS_DIR;
|
||||
}
|
||||
|
||||
let mtime = match m.modified() {
|
||||
|
@ -292,13 +292,19 @@ impl PendingChanges for WatchmanFileSystem {
|
||||
"watchman file"
|
||||
);
|
||||
|
||||
let meta = Metadata::from_stat(
|
||||
file.mode.into_inner() as u32,
|
||||
file.size.into_inner(),
|
||||
file.mtime.into_inner(),
|
||||
);
|
||||
if meta.is_dir() {
|
||||
// Filter directories out of results.
|
||||
return None;
|
||||
}
|
||||
|
||||
let fs_meta = if *file.exists {
|
||||
if use_watchman_metadata {
|
||||
Some(Some(Metadata::from_stat(
|
||||
file.mode.into_inner() as u32,
|
||||
file.size.into_inner(),
|
||||
file.mtime.into_inner(),
|
||||
)))
|
||||
Some(Some(meta))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user