##// END OF EJS Templates
rust: change &PathBuf parameters to &Path...
Simon Sapin -
r46750:cc6faec6 default
parent child Browse files
Show More
@@ -71,7 +71,7 b' impl From<RevlogError> for CatRevError {'
71
71
72 /// List files under Mercurial control at a given revision.
72 /// List files under Mercurial control at a given revision.
73 pub struct CatRev<'a> {
73 pub struct CatRev<'a> {
74 root: &'a PathBuf,
74 root: &'a Path,
75 /// The revision to cat the files from.
75 /// The revision to cat the files from.
76 rev: &'a str,
76 rev: &'a str,
77 /// The files to output.
77 /// The files to output.
@@ -88,7 +88,7 b" pub struct CatRev<'a> {"
88
88
89 impl<'a> CatRev<'a> {
89 impl<'a> CatRev<'a> {
90 pub fn new(
90 pub fn new(
91 root: &'a PathBuf,
91 root: &'a Path,
92 rev: &'a str,
92 rev: &'a str,
93 files: &'a [HgPathBuf],
93 files: &'a [HgPathBuf],
94 ) -> Result<Self, CatRevError> {
94 ) -> Result<Self, CatRevError> {
@@ -16,7 +16,7 b' use crate::{DirstateParseError, EntrySta'
16 use rayon::prelude::*;
16 use rayon::prelude::*;
17 use std::convert::From;
17 use std::convert::From;
18 use std::fs;
18 use std::fs;
19 use std::path::PathBuf;
19 use std::path::Path;
20
20
21 /// Kind of error encountered by `ListDirstateTrackedFiles`
21 /// Kind of error encountered by `ListDirstateTrackedFiles`
22 #[derive(Debug)]
22 #[derive(Debug)]
@@ -57,7 +57,7 b' pub struct ListDirstateTrackedFiles {'
57 }
57 }
58
58
59 impl ListDirstateTrackedFiles {
59 impl ListDirstateTrackedFiles {
60 pub fn new(root: &PathBuf) -> Result<Self, ListDirstateTrackedFilesError> {
60 pub fn new(root: &Path) -> Result<Self, ListDirstateTrackedFilesError> {
61 let dirstate = root.join(".hg/dirstate");
61 let dirstate = root.join(".hg/dirstate");
62 let content = fs::read(&dirstate)?;
62 let content = fs::read(&dirstate)?;
63 Ok(Self { content })
63 Ok(Self { content })
@@ -152,11 +152,11 b" pub struct ListRevTrackedFiles<'a> {"
152
152
153 impl<'a> ListRevTrackedFiles<'a> {
153 impl<'a> ListRevTrackedFiles<'a> {
154 pub fn new(
154 pub fn new(
155 root: &PathBuf,
155 root: &Path,
156 rev: &'a str,
156 rev: &'a str,
157 ) -> Result<Self, ListRevTrackedFilesError> {
157 ) -> Result<Self, ListRevTrackedFilesError> {
158 let changelog = Changelog::open(&root)?;
158 let changelog = Changelog::open(root)?;
159 let manifest = Manifest::open(&root)?;
159 let manifest = Manifest::open(root)?;
160
160
161 Ok(Self {
161 Ok(Self {
162 rev,
162 rev,
@@ -1,7 +1,7 b''
1 use crate::revlog::revlog::{Revlog, RevlogError};
1 use crate::revlog::revlog::{Revlog, RevlogError};
2 use crate::revlog::NodePrefixRef;
2 use crate::revlog::NodePrefixRef;
3 use crate::revlog::Revision;
3 use crate::revlog::Revision;
4 use std::path::PathBuf;
4 use std::path::Path;
5
5
6 /// A specialized `Revlog` to work with `changelog` data format.
6 /// A specialized `Revlog` to work with `changelog` data format.
7 pub struct Changelog {
7 pub struct Changelog {
@@ -11,7 +11,7 b' pub struct Changelog {'
11
11
12 impl Changelog {
12 impl Changelog {
13 /// Open the `changelog` of a repository given by its root.
13 /// Open the `changelog` of a repository given by its root.
14 pub fn open(root: &PathBuf) -> Result<Self, RevlogError> {
14 pub fn open(root: &Path) -> Result<Self, RevlogError> {
15 let index_file = root.join(".hg/store/00changelog.i");
15 let index_file = root.join(".hg/store/00changelog.i");
16 let revlog = Revlog::open(&index_file, None)?;
16 let revlog = Revlog::open(&index_file, None)?;
17 Ok(Self { revlog })
17 Ok(Self { revlog })
@@ -2,7 +2,7 b' use crate::revlog::revlog::{Revlog, Revl'
2 use crate::revlog::NodePrefixRef;
2 use crate::revlog::NodePrefixRef;
3 use crate::revlog::Revision;
3 use crate::revlog::Revision;
4 use crate::utils::hg_path::HgPath;
4 use crate::utils::hg_path::HgPath;
5 use std::path::PathBuf;
5 use std::path::Path;
6
6
7 /// A specialized `Revlog` to work with `manifest` data format.
7 /// A specialized `Revlog` to work with `manifest` data format.
8 pub struct Manifest {
8 pub struct Manifest {
@@ -12,7 +12,7 b' pub struct Manifest {'
12
12
13 impl Manifest {
13 impl Manifest {
14 /// Open the `manifest` of a repository given by its root.
14 /// Open the `manifest` of a repository given by its root.
15 pub fn open(root: &PathBuf) -> Result<Self, RevlogError> {
15 pub fn open(root: &Path) -> Result<Self, RevlogError> {
16 let index_file = root.join(".hg/store/00manifest.i");
16 let index_file = root.join(".hg/store/00manifest.i");
17 let revlog = Revlog::open(&index_file, None)?;
17 let revlog = Revlog::open(&index_file, None)?;
18 Ok(Self { revlog })
18 Ok(Self { revlog })
@@ -14,7 +14,7 b' use hg::operations::{'
14 use hg::requirements;
14 use hg::requirements;
15 use hg::utils::files::{get_bytes_from_path, relativize_path};
15 use hg::utils::files::{get_bytes_from_path, relativize_path};
16 use hg::utils::hg_path::{HgPath, HgPathBuf};
16 use hg::utils::hg_path::{HgPath, HgPathBuf};
17 use std::path::PathBuf;
17 use std::path::Path;
18
18
19 pub const HELP_TEXT: &str = "
19 pub const HELP_TEXT: &str = "
20 List tracked files.
20 List tracked files.
@@ -34,13 +34,13 b" impl<'a> FilesCommand<'a> {"
34 fn display_files(
34 fn display_files(
35 &self,
35 &self,
36 ui: &Ui,
36 ui: &Ui,
37 root: &PathBuf,
37 root: &Path,
38 files: impl IntoIterator<Item = &'a HgPath>,
38 files: impl IntoIterator<Item = &'a HgPath>,
39 ) -> Result<(), CommandError> {
39 ) -> Result<(), CommandError> {
40 let cwd = std::env::current_dir()
40 let cwd = std::env::current_dir()
41 .or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?;
41 .or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?;
42 let rooted_cwd = cwd
42 let rooted_cwd = cwd
43 .strip_prefix(&root)
43 .strip_prefix(root)
44 .expect("cwd was already checked within the repository");
44 .expect("cwd was already checked within the repository");
45 let rooted_cwd = HgPathBuf::from(get_bytes_from_path(rooted_cwd));
45 let rooted_cwd = HgPathBuf::from(get_bytes_from_path(rooted_cwd));
46
46
General Comments 0
You need to be logged in to leave comments. Login now