-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add changes-since command to eden notify subcommand
Summary: # Context We are introducing EdenFS notifications to support scalable and ergonomic file system notifications for EdenFS mounts. # This Diff Adds a new command (`changes-since`) to the `eden nofity` subcommand. This command will return all of the changes since the provided position for the given mount. # Technical Details Added new module for changes since command that does nothing - yet # Next Steps Implement the `changes-since` command to `eden notify` then iterate on the `streamChangesSinceV2` Thrift endpoint. # Discussion Points None Differential Revision: D65774220 fbshipit-source-id: 0ef4005345c5c5f8ab7dd50c599371b259b4ec84
- Loading branch information
1 parent
b891d3e
commit e4baaef
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
eden/fs/cli_rs/edenfs-commands/src/notify/changes_since.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This software may be used and distributed according to the terms of the | ||
* GNU General Public License version 2. | ||
*/ | ||
|
||
//! edenfsctl notify changes-since | ||
|
||
use std::path::PathBuf; | ||
|
||
use anyhow::anyhow; | ||
use anyhow::Context; | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use clap::Parser; | ||
use edenfs_client::EdenFsInstance; | ||
use edenfs_utils::bytes_from_path; | ||
use hg_util::path::expand_path; | ||
|
||
use crate::util::locate_repo_root; | ||
use crate::ExitCode; | ||
|
||
// TODO: add a --json flag to print the output in JSON format | ||
#[derive(Parser, Debug)] | ||
#[clap(about = "Returns the changes since the given EdenFS journal position")] | ||
pub struct ChangesSinceCmd { | ||
#[clap(parse(from_str = expand_path))] | ||
/// Path to the mount point | ||
mount_point: Option<PathBuf>, | ||
} | ||
|
||
impl ChangesSinceCmd { | ||
fn get_mount_point(&self) -> Result<PathBuf> { | ||
if let Some(path) = &self.mount_point { | ||
Ok(path.clone()) | ||
} else { | ||
locate_repo_root( | ||
&std::env::current_dir().context("Unable to retrieve current working directory")?, | ||
) | ||
.map(|p| p.to_path_buf()) | ||
.ok_or_else(|| anyhow!("Unable to locate repository root")) | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl crate::Subcommand for ChangesSinceCmd { | ||
#[cfg(not(fbcode_build))] | ||
async fn run(&self) -> Result<ExitCode> { | ||
eprintln!("not supported in non-fbcode build"); | ||
Ok(1) | ||
} | ||
|
||
#[cfg(fbcode_build)] | ||
async fn run(&self) -> Result<ExitCode> { | ||
let instance = EdenFsInstance::global(); | ||
let _client = instance.connect(None).await?; | ||
let mount_point_path = self.get_mount_point()?; | ||
let _mount_point = bytes_from_path(mount_point_path)?; | ||
|
||
Ok(0) | ||
} | ||
} |