Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Watchman config better, new jj debug watchman status command #3484

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
evaluates to true if the operation was a snapshot created by a non-mutating
command (e.g. `jj log`).

* You can check whether Watchman fsmonitor is enabled or installed with the new
`jj debug watchman status` command.

### Fixed bugs

* Revsets now support `\`-escapes in string literal.
Expand Down
27 changes: 27 additions & 0 deletions cli/src/commands/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ pub struct DebugTreeArgs {

#[derive(Subcommand, Clone, Debug)]
pub enum DebugWatchmanSubcommand {
/// Check whether `watchman` is enabled and whether it's correctly installed
Status,
QueryClock,
QueryChangedFiles,
ResetClock,
Expand Down Expand Up @@ -367,6 +369,31 @@ fn cmd_debug_watchman(
let mut workspace_command = command.workspace_helper(ui)?;
let repo = workspace_command.repo().clone();
match subcommand {
DebugWatchmanSubcommand::Status => {
// TODO(ilyagr): It would be nice to add colors here
match command.settings().fsmonitor_kind()? {
jj_lib::fsmonitor::FsmonitorKind::Watchman => {
writeln!(ui.stdout(), "Watchman is enabled via `core.fsmonitor`.")?
}
jj_lib::fsmonitor::FsmonitorKind::None => writeln!(
ui.stdout(),
"Watchman is disabled. Set `core.fsmonitor=\"watchman\"` to \
enable.\nAttempting to contact the `watchman` CLI regardless..."
)?,
other_fsmonitor => {
return Err(user_error(format!(
"This command does not support the currently enabled filesystem monitor: \
{other_fsmonitor:?}."
)))
}
};
let wc = check_local_disk_wc(workspace_command.working_copy().as_any())?;
let _ = wc.query_watchman()?;
writeln!(
ui.stdout(),
"The watchman server seems to be installed and working correctly."
)?;
}
DebugWatchmanSubcommand::QueryClock => {
let wc = check_local_disk_wc(workspace_command.working_copy().as_any())?;
let (clock, _changed_files) = wc.query_watchman()?;
Expand Down
10 changes: 10 additions & 0 deletions cli/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@
}
}
},
"core": {
"type": "object",
"properties": {
"fsmonitor": {
"type": "string",
"enum": ["none", "watchman"],
"description": "Whether to use an external filesystem monitor, useful for large repos"
}
}
},
"colors": {
"type": "object",
"description": "Mapping from jj formatter labels to colors",
Expand Down
6 changes: 5 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,17 @@ In large repositories, it may be beneficial to use a "filesystem monitor" to
track changes to the working copy. This allows `jj` to take working copy
snapshots without having to rescan the entire working copy.

This is governed by the `core.fsmonitor` option. Currently, the valid values are
`"none"` or `"watchman"`.

### Watchman

To configure the Watchman filesystem monitor, set
`core.fsmonitor = "watchman"`. Ensure that you have [installed the Watchman
executable on your system](https://facebook.github.io/watchman/docs/install).

Debugging commands are available under `jj debug watchman`.
You can check whether Watchman is enabled and whether it is installed correctly
using `jj debug watchman status`.

## Ways to specify `jj` config: details

Expand Down
2 changes: 1 addition & 1 deletion lib/src/fsmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::path::PathBuf;
use std::str::FromStr;

/// The recognized kinds of filesystem monitors.
#[derive(Eq, PartialEq)]
#[derive(Eq, PartialEq, Clone, Debug)]
pub enum FsmonitorKind {
/// The Watchman filesystem monitor (<https://facebook.github.io/watchman/>).
Watchman,
Expand Down