Show More
@@ -53,21 +53,35 b" fn display_files<'a>(" | |||||
53 | repo: &Repo, |
|
53 | repo: &Repo, | |
54 | files: impl IntoIterator<Item = &'a HgPath>, |
|
54 | files: impl IntoIterator<Item = &'a HgPath>, | |
55 | ) -> Result<(), CommandError> { |
|
55 | ) -> Result<(), CommandError> { | |
56 | let cwd = HgPathBuf::from(get_bytes_from_path(hg::utils::current_dir()?)); |
|
56 | let mut stdout = ui.stdout_buffer(); | |
|
57 | ||||
|
58 | let cwd = current_dir()?; | |||
57 | let working_directory = repo.working_directory_path(); |
|
59 | let working_directory = repo.working_directory_path(); | |
58 |
let working_directory = c |
|
60 | let working_directory = cwd.join(working_directory); // Make it absolute | |
|
61 | ||||
|
62 | let mut any = false; | |||
|
63 | if let Ok(cwd_relative_to_repo) = cwd.strip_prefix(&working_directory) { | |||
|
64 | // The current directory is inside the repo, so we can work with | |||
|
65 | // relative paths | |||
|
66 | let cwd = HgPathBuf::from(get_bytes_from_path(cwd_relative_to_repo)); | |||
|
67 | for file in files { | |||
|
68 | any = true; | |||
|
69 | stdout.write_all(relativize_path(&file, &cwd).as_ref())?; | |||
|
70 | stdout.write_all(b"\n")?; | |||
|
71 | } | |||
|
72 | } else { | |||
59 | let working_directory = |
|
73 | let working_directory = | |
60 | HgPathBuf::from(get_bytes_from_path(working_directory)); |
|
74 | HgPathBuf::from(get_bytes_from_path(working_directory)); | |
61 |
|
75 | let cwd = HgPathBuf::from(get_bytes_from_path(cwd)); | ||
62 | let mut stdout = ui.stdout_buffer(); |
|
|||
63 |
|
||||
64 | let mut any = false; |
|
|||
65 | for file in files { |
|
76 | for file in files { | |
66 | any = true; |
|
77 | any = true; | |
|
78 | // Absolute path in the filesystem | |||
67 | let file = working_directory.join(file); |
|
79 | let file = working_directory.join(file); | |
68 | stdout.write_all(relativize_path(&file, &cwd).as_ref())?; |
|
80 | stdout.write_all(relativize_path(&file, &cwd).as_ref())?; | |
69 | stdout.write_all(b"\n")?; |
|
81 | stdout.write_all(b"\n")?; | |
70 | } |
|
82 | } | |
|
83 | } | |||
|
84 | ||||
71 | stdout.flush()?; |
|
85 | stdout.flush()?; | |
72 | if any { |
|
86 | if any { | |
73 | Ok(()) |
|
87 | Ok(()) |
General Comments 0
You need to be logged in to leave comments.
Login now