equal
deleted
inserted
replaced
1 use crate::commands::Command; |
1 use crate::commands::Command; |
2 use crate::error::{CommandError, CommandErrorKind}; |
2 use crate::error::{CommandError, CommandErrorKind}; |
3 use crate::ui::Ui; |
3 use crate::ui::Ui; |
4 use hg::operations::{ListTrackedFiles, ListTrackedFilesErrorKind}; |
4 use hg::operations::{ListTrackedFiles, ListTrackedFilesErrorKind}; |
|
5 use hg::utils::files::{get_bytes_from_path, relativize_path}; |
|
6 use hg::utils::hg_path::HgPathBuf; |
5 |
7 |
6 pub const HELP_TEXT: &str = " |
8 pub const HELP_TEXT: &str = " |
7 List tracked files. |
9 List tracked files. |
8 |
10 |
9 Returns 0 on success. |
11 Returns 0 on success. |
36 b"abort: parse error\n".to_vec(), |
38 b"abort: parse error\n".to_vec(), |
37 )) |
39 )) |
38 } |
40 } |
39 })?; |
41 })?; |
40 |
42 |
|
43 let cwd = std::env::current_dir() |
|
44 .or_else(|e| Err(CommandErrorKind::CurrentDirNotFound(e)))?; |
|
45 let rooted_cwd = cwd |
|
46 .strip_prefix(operation_builder.get_root()) |
|
47 .expect("cwd was already checked within the repository"); |
|
48 let rooted_cwd = HgPathBuf::from(get_bytes_from_path(rooted_cwd)); |
|
49 |
41 let mut stdout = self.ui.stdout_buffer(); |
50 let mut stdout = self.ui.stdout_buffer(); |
|
51 |
42 for file in files { |
52 for file in files { |
43 stdout.write_all(file.as_bytes())?; |
53 stdout.write_all(relativize_path(file, &rooted_cwd).as_ref())?; |
44 stdout.write_all(b"\n")?; |
54 stdout.write_all(b"\n")?; |
45 } |
55 } |
46 stdout.flush()?; |
56 stdout.flush()?; |
47 |
57 |
48 Ok(()) |
58 Ok(()) |