diff --git a/rust/hg-core/src/operations/cat.rs b/rust/hg-core/src/operations/cat.rs --- a/rust/hg-core/src/operations/cat.rs +++ b/rust/hg-core/src/operations/cat.rs @@ -71,7 +71,7 @@ /// List files under Mercurial control at a given revision. pub struct CatRev<'a> { - root: &'a PathBuf, + root: &'a Path, /// The revision to cat the files from. rev: &'a str, /// The files to output. @@ -88,7 +88,7 @@ impl<'a> CatRev<'a> { pub fn new( - root: &'a PathBuf, + root: &'a Path, rev: &'a str, files: &'a [HgPathBuf], ) -> Result { diff --git a/rust/hg-core/src/operations/list_tracked_files.rs b/rust/hg-core/src/operations/list_tracked_files.rs --- a/rust/hg-core/src/operations/list_tracked_files.rs +++ b/rust/hg-core/src/operations/list_tracked_files.rs @@ -16,7 +16,7 @@ use rayon::prelude::*; use std::convert::From; use std::fs; -use std::path::PathBuf; +use std::path::Path; /// Kind of error encountered by `ListDirstateTrackedFiles` #[derive(Debug)] @@ -57,7 +57,7 @@ } impl ListDirstateTrackedFiles { - pub fn new(root: &PathBuf) -> Result { + pub fn new(root: &Path) -> Result { let dirstate = root.join(".hg/dirstate"); let content = fs::read(&dirstate)?; Ok(Self { content }) @@ -152,11 +152,11 @@ impl<'a> ListRevTrackedFiles<'a> { pub fn new( - root: &PathBuf, + root: &Path, rev: &'a str, ) -> Result { - let changelog = Changelog::open(&root)?; - let manifest = Manifest::open(&root)?; + let changelog = Changelog::open(root)?; + let manifest = Manifest::open(root)?; Ok(Self { rev, diff --git a/rust/hg-core/src/revlog/changelog.rs b/rust/hg-core/src/revlog/changelog.rs --- a/rust/hg-core/src/revlog/changelog.rs +++ b/rust/hg-core/src/revlog/changelog.rs @@ -1,7 +1,7 @@ use crate::revlog::revlog::{Revlog, RevlogError}; use crate::revlog::NodePrefixRef; use crate::revlog::Revision; -use std::path::PathBuf; +use std::path::Path; /// A specialized `Revlog` to work with `changelog` data format. pub struct Changelog { @@ -11,7 +11,7 @@ impl Changelog { /// Open the `changelog` of a repository given by its root. - pub fn open(root: &PathBuf) -> Result { + pub fn open(root: &Path) -> Result { let index_file = root.join(".hg/store/00changelog.i"); let revlog = Revlog::open(&index_file, None)?; Ok(Self { revlog }) diff --git a/rust/hg-core/src/revlog/manifest.rs b/rust/hg-core/src/revlog/manifest.rs --- a/rust/hg-core/src/revlog/manifest.rs +++ b/rust/hg-core/src/revlog/manifest.rs @@ -2,7 +2,7 @@ use crate::revlog::NodePrefixRef; use crate::revlog::Revision; use crate::utils::hg_path::HgPath; -use std::path::PathBuf; +use std::path::Path; /// A specialized `Revlog` to work with `manifest` data format. pub struct Manifest { @@ -12,7 +12,7 @@ impl Manifest { /// Open the `manifest` of a repository given by its root. - pub fn open(root: &PathBuf) -> Result { + pub fn open(root: &Path) -> Result { let index_file = root.join(".hg/store/00manifest.i"); let revlog = Revlog::open(&index_file, None)?; Ok(Self { revlog }) diff --git a/rust/rhg/src/commands/files.rs b/rust/rhg/src/commands/files.rs --- a/rust/rhg/src/commands/files.rs +++ b/rust/rhg/src/commands/files.rs @@ -14,7 +14,7 @@ use hg::requirements; use hg::utils::files::{get_bytes_from_path, relativize_path}; use hg::utils::hg_path::{HgPath, HgPathBuf}; -use std::path::PathBuf; +use std::path::Path; pub const HELP_TEXT: &str = " List tracked files. @@ -34,13 +34,13 @@ fn display_files( &self, ui: &Ui, - root: &PathBuf, + root: &Path, files: impl IntoIterator, ) -> Result<(), CommandError> { let cwd = std::env::current_dir() .or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?; let rooted_cwd = cwd - .strip_prefix(&root) + .strip_prefix(root) .expect("cwd was already checked within the repository"); let rooted_cwd = HgPathBuf::from(get_bytes_from_path(rooted_cwd));