Skip to content

Commit

Permalink
fsmonitor: allow core.fsmonitor = "none" to disable
Browse files Browse the repository at this point in the history
When doing things like testing snapshot performance differences,
this allows you to turn off the monitor, no matter what the enabled
user or repository configuration has, e.g.

    jj st --config-toml='core.fsmonitor="none"'

Signed-off-by: Austin Seipp <[email protected]>
  • Loading branch information
thoughtpolice committed Feb 19, 2024
1 parent ff5eefd commit ba4e7a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/src/fsmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ pub enum FsmonitorKind {
/// reporting.
changed_files: Vec<PathBuf>,
},

/// No filesystem monitor. This is the default if nothing is configured, but
/// also makes it possible to turn off the monitor on a case-by-case basis
/// when the user gives an option like
/// `--config-toml=fsmonitor_kind="none"`; useful when e.g. when doing
/// analysis of snapshot performance.
None,
}

impl FromStr for FsmonitorKind {
Expand All @@ -45,6 +52,7 @@ impl FromStr for FsmonitorKind {
"test" => Err(config::ConfigError::Message(
"cannot use test fsmonitor in real repository".to_string(),
)),
"none" => Ok(Self::None),
other => Err(config::ConfigError::Message(format!(
"unknown fsmonitor kind: {}",
other
Expand Down
1 change: 1 addition & 0 deletions lib/src/local_working_copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ impl TreeState {
) -> Result<FsmonitorMatcher, SnapshotError> {
let (watchman_clock, changed_files) = match fsmonitor_kind {
None => (None, None),
Some(FsmonitorKind::None) => (None, None),
Some(FsmonitorKind::Test { changed_files }) => (None, Some(changed_files)),
Some(FsmonitorKind::Watchman) => {
if cfg!(feature = "watchman") {
Expand Down

0 comments on commit ba4e7a9

Please sign in to comment.