Mercurial > public > mercurial-scm > hg-stable
comparison rust/rhg/src/commands/files.rs @ 46135:cc6faec62cb7
rust: change &PathBuf parameters to &Path
This is just as useful in function bodies, and a less strict requirement for callers.
Differential Revision: https://phab.mercurial-scm.org/D9594
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 14 Dec 2020 13:47:44 +0100 |
parents | 8d6164098782 |
children | dca9cb99971c |
comparison
equal
deleted
inserted
replaced
46134:0a4d47f4337b | 46135:cc6faec62cb7 |
---|---|
12 ListRevTrackedFilesErrorKind, | 12 ListRevTrackedFilesErrorKind, |
13 }; | 13 }; |
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. |
21 | 21 |
22 Returns 0 on success. | 22 Returns 0 on success. |
32 } | 32 } |
33 | 33 |
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 |
47 let mut stdout = ui.stdout_buffer(); | 47 let mut stdout = ui.stdout_buffer(); |
48 | 48 |