mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-27 14:57:14 +00:00
Switch from a private extension to the newly release 0.9.0
This commit is contained in:
parent
bbe71626ee
commit
95fbf9f3d0
5 changed files with 46 additions and 244 deletions
53
Cargo.lock
generated
53
Cargo.lock
generated
|
@ -248,16 +248,6 @@ version = "1.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"iovec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.6.0"
|
||||
|
@ -1634,15 +1624,6 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iovec"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is-terminal"
|
||||
version = "0.4.12"
|
||||
|
@ -1743,7 +1724,7 @@ dependencies = [
|
|||
"async-trait",
|
||||
"backoff",
|
||||
"blake2",
|
||||
"bytes 1.6.0",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"config",
|
||||
"criterion",
|
||||
|
@ -2352,7 +2333,7 @@ version = "0.12.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29"
|
||||
dependencies = [
|
||||
"bytes 1.6.0",
|
||||
"bytes",
|
||||
"prost-derive",
|
||||
]
|
||||
|
||||
|
@ -2362,8 +2343,8 @@ version = "0.12.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4"
|
||||
dependencies = [
|
||||
"bytes 1.6.0",
|
||||
"heck 0.4.1",
|
||||
"bytes",
|
||||
"heck 0.5.0",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"multimap",
|
||||
|
@ -2672,17 +2653,27 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_bser"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b929ea725591083cbca8b8ea178ed6efc918eccd40b784e199ce88967104199"
|
||||
checksum = "a56b4bcc15e42e5b5ae16c6f75582bef80d36c6ffe2c03b1b5317754b38f8717"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"byteorder",
|
||||
"bytes 0.4.12",
|
||||
"bytes",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_bytes"
|
||||
version = "0.11.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.203"
|
||||
|
@ -3055,7 +3046,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a"
|
||||
dependencies = [
|
||||
"backtrace",
|
||||
"bytes 1.6.0",
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
"num_cpus",
|
||||
|
@ -3084,7 +3075,7 @@ version = "0.6.10"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507"
|
||||
dependencies = [
|
||||
"bytes 1.6.0",
|
||||
"bytes",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
|
@ -3395,12 +3386,12 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
|||
|
||||
[[package]]
|
||||
name = "watchman_client"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "839fea2d85719bb69089290d7970bba2131f544448db8f990ea75813c30775ca"
|
||||
checksum = "88bc4c9bb443a7aae10d4fa7807bffc397805315e2305288c90c80e2f66cfb52"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes 1.6.0",
|
||||
"bytes",
|
||||
"futures 0.3.30",
|
||||
"maplit",
|
||||
"serde",
|
||||
|
|
|
@ -108,7 +108,7 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
|
|||
] }
|
||||
unicode-width = "0.1.13"
|
||||
version_check = "0.9.4"
|
||||
watchman_client = { version = "0.8.0" }
|
||||
watchman_client = { version = "0.9.0" }
|
||||
whoami = "1.5.1"
|
||||
winreg = "0.52"
|
||||
zstd = "0.12.4"
|
||||
|
|
|
@ -91,11 +91,7 @@ pub mod watchman {
|
|||
use tracing::{info, instrument};
|
||||
use watchman_client::expr;
|
||||
use watchman_client::prelude::{
|
||||
Clock as InnerClock, ClockSpec, NameOnly, QueryRequestCommon, QueryResult,
|
||||
};
|
||||
|
||||
use crate::fsmonitor_watchman_extensions::{
|
||||
list_triggers, register_trigger, remove_trigger, TriggerRequest,
|
||||
Clock as InnerClock, ClockSpec, NameOnly, QueryRequestCommon, QueryResult, TriggerRequest,
|
||||
};
|
||||
|
||||
/// Represents an instance in time from the perspective of the filesystem
|
||||
|
@ -266,7 +262,9 @@ pub mod watchman {
|
|||
#[instrument(skip(self))]
|
||||
async fn is_trigger_registered(&self) -> Result<bool, Error> {
|
||||
info!("Checking for an existing Watchman trigger...");
|
||||
Ok(list_triggers(&self.client, &self.resolved_root)
|
||||
Ok(self
|
||||
.client
|
||||
.list_triggers(&self.resolved_root)
|
||||
.await
|
||||
.map_err(Error::WatchmanTriggerError)?
|
||||
.triggers
|
||||
|
@ -278,8 +276,8 @@ pub mod watchman {
|
|||
#[instrument(skip(self))]
|
||||
async fn register_trigger(&self) -> Result<(), Error> {
|
||||
info!("Registering Watchman trigger...");
|
||||
register_trigger(
|
||||
&self.client,
|
||||
self.client
|
||||
.register_trigger(
|
||||
&self.resolved_root,
|
||||
TriggerRequest {
|
||||
name: "jj-background-monitor".to_string(),
|
||||
|
@ -302,7 +300,8 @@ pub mod watchman {
|
|||
#[instrument(skip(self))]
|
||||
async fn unregister_trigger(&self) -> Result<(), Error> {
|
||||
info!("Unregistering Watchman trigger...");
|
||||
remove_trigger(&self.client, &self.resolved_root, "jj-background-monitor")
|
||||
self.client
|
||||
.remove_trigger(&self.resolved_root, "jj-background-monitor")
|
||||
.await
|
||||
.map_err(Error::WatchmanTriggerError)?;
|
||||
Ok(())
|
||||
|
|
|
@ -1,186 +0,0 @@
|
|||
// Copyright 2024 The Jujutsu Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// TODO: remove this file after watchman adopts and releases it.
|
||||
// https://github.com/facebook/watchman/pull/1221
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
use watchman_client::expr::Expr;
|
||||
use watchman_client::{Client, Error, ResolvedRoot};
|
||||
|
||||
/// Registers a trigger.
|
||||
pub async fn register_trigger(
|
||||
client: &Client,
|
||||
root: &ResolvedRoot,
|
||||
request: TriggerRequest,
|
||||
) -> Result<TriggerResponse, Error> {
|
||||
let response: TriggerResponse = client
|
||||
.generic_request(TriggerCommand(
|
||||
"trigger",
|
||||
root.project_root().to_path_buf(),
|
||||
request,
|
||||
))
|
||||
.await?;
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
/// Removes a registered trigger.
|
||||
pub async fn remove_trigger(
|
||||
client: &Client,
|
||||
root: &ResolvedRoot,
|
||||
name: &str,
|
||||
) -> Result<TriggerDelResponse, Error> {
|
||||
let response: TriggerDelResponse = client
|
||||
.generic_request(TriggerDelCommand(
|
||||
"trigger-del",
|
||||
root.project_root().to_path_buf(),
|
||||
name.into(),
|
||||
))
|
||||
.await?;
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
/// Lists registered triggers.
|
||||
pub async fn list_triggers(
|
||||
client: &Client,
|
||||
root: &ResolvedRoot,
|
||||
) -> Result<TriggerListResponse, Error> {
|
||||
let response: TriggerListResponse = client
|
||||
.generic_request(TriggerListCommand(
|
||||
"trigger-list",
|
||||
root.project_root().to_path_buf(),
|
||||
))
|
||||
.await?;
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
/// The `trigger` command request.
|
||||
///
|
||||
/// The fields are explained in detail here:
|
||||
/// <https://facebook.github.io/watchman/docs/cmd/trigger#extended-syntax>
|
||||
#[derive(Deserialize, Serialize, Default, Clone, Debug)]
|
||||
pub struct TriggerRequest {
|
||||
/// Defines the name of the trigger.
|
||||
pub name: String,
|
||||
|
||||
/// Specifies the command to invoke.
|
||||
pub command: Vec<String>,
|
||||
|
||||
/// It true, matching files (up to system limits) will be added to the
|
||||
/// command's execution args.
|
||||
#[serde(default, skip_serializing_if = "is_false")]
|
||||
pub append_files: bool,
|
||||
|
||||
/// Specifies the expression used to filter candidate matches.
|
||||
#[serde(skip_serializing_if = "Option::is_none", skip_deserializing)]
|
||||
pub expression: Option<Expr>,
|
||||
|
||||
/// Configure the way `stdin` is configured for the executed trigger.
|
||||
#[serde(
|
||||
default,
|
||||
skip_serializing_if = "TriggerStdinConfig::is_devnull",
|
||||
serialize_with = "TriggerStdinConfig::serialize",
|
||||
skip_deserializing
|
||||
)]
|
||||
pub stdin: TriggerStdinConfig,
|
||||
|
||||
/// Specifies a file to write the output stream to. Prefix with `>` to
|
||||
/// overwrite and `>>` to append.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub stdout: Option<String>,
|
||||
|
||||
/// Specifies a file to write the error stream to. Prefix with `>` to
|
||||
/// overwrite and `>>` to append.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub stderr: Option<String>,
|
||||
|
||||
/// Specifies a limit on the number of files reported on stdin when stdin is
|
||||
/// set to hold the set of matched files.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub max_files_stdin: Option<u64>,
|
||||
|
||||
/// Specifies the working directory that will be set prior to spawning the
|
||||
/// process. The default is to set the working directory to the watched
|
||||
/// root. The value of this property is a string that will be interpreted
|
||||
/// relative to the watched root.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub chdir: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum TriggerStdinConfig {
|
||||
DevNull,
|
||||
FieldNames(Vec<String>),
|
||||
NamePerLine,
|
||||
}
|
||||
|
||||
impl Default for TriggerStdinConfig {
|
||||
fn default() -> Self {
|
||||
Self::DevNull
|
||||
}
|
||||
}
|
||||
|
||||
impl TriggerStdinConfig {
|
||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
match self {
|
||||
Self::DevNull => serializer.serialize_str("/dev/null"),
|
||||
Self::FieldNames(names) => serializer.collect_seq(names.iter()),
|
||||
Self::NamePerLine => serializer.serialize_str("NAME_PER_LINE"),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_devnull(&self) -> bool {
|
||||
matches!(self, Self::DevNull)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone, Debug)]
|
||||
pub struct TriggerCommand(pub &'static str, pub PathBuf, pub TriggerRequest);
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct TriggerResponse {
|
||||
pub version: String,
|
||||
pub disposition: String,
|
||||
pub triggerid: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone, Debug)]
|
||||
pub struct TriggerDelCommand(pub &'static str, pub PathBuf, pub String);
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct TriggerDelResponse {
|
||||
pub version: String,
|
||||
pub deleted: bool,
|
||||
pub trigger: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone, Debug)]
|
||||
pub struct TriggerListCommand(pub &'static str, pub PathBuf);
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct TriggerListResponse {
|
||||
pub version: String,
|
||||
pub triggers: Vec<TriggerRequest>,
|
||||
}
|
||||
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
fn is_false(v: &bool) -> bool {
|
||||
!*v
|
||||
}
|
|
@ -44,8 +44,6 @@ pub mod fileset;
|
|||
mod fileset_parser;
|
||||
pub mod fmt_util;
|
||||
pub mod fsmonitor;
|
||||
#[cfg(feature = "watchman")]
|
||||
pub mod fsmonitor_watchman_extensions;
|
||||
#[cfg(feature = "git")]
|
||||
pub mod git;
|
||||
#[cfg(feature = "git")]
|
||||
|
|
Loading…
Reference in a new issue