-
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.
Refactor client usage into edenfs-client
Summary: # Context We are introducing EdenFS notifications to support scalable and ergonomic file system notifications for EdenFS mounts. # This Diff I noticed that we have a couple of patterns for how to integrate with EdenFS' Thrift API in our CLI code. I am choosing here to embrace capturing most (not quite all yet) of these details in the client library. This diff refactors some previous code to get journal position from individual command to the library. # Next Steps Implement the `changes-since` command to `eden notify` then iterate on the `streamChangesSinceV2` Thrift endpoint. # Discussion Points None Differential Revision: D65834704 fbshipit-source-id: 3af76bb4db698dd116dae41cdd5dea6d8d500a9f
- Loading branch information
1 parent
ada5411
commit d148c22
Showing
7 changed files
with
58 additions
and
30 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
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
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,31 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
use std::path::Path; | ||
use std::path::PathBuf; | ||
|
||
use anyhow::anyhow; | ||
use anyhow::Context; | ||
use anyhow::Result; | ||
|
||
/// Traverse up and locate the repository root | ||
pub fn locate_repo_root(path: &Path) -> Option<&Path> { | ||
path.ancestors() | ||
.find(|p| p.join(".hg").is_dir() || p.join(".git").is_dir()) | ||
} | ||
|
||
pub fn get_mount_point(mount_point: &Option<PathBuf>) -> Result<PathBuf> { | ||
if let Some(path) = 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")) | ||
} | ||
} |
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
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
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
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