Show More
@@ -1,7 +1,8 b'' | |||
|
1 | 1 | use crate::error::CommandError; |
|
2 | use crate::ui::Ui; | |
|
2 | use crate::ui::{print_narrow_sparse_warnings, Ui}; | |
|
3 | 3 | use crate::utils::path_utils::RelativizePaths; |
|
4 | 4 | use clap::Arg; |
|
5 | use hg::narrow; | |
|
5 | 6 | use hg::operations::list_rev_tracked_files; |
|
6 | 7 | use hg::repo::Repo; |
|
7 | 8 | use hg::utils::filter_map_results; |
@@ -60,27 +61,33 b' pub fn run(invocation: &crate::CliInvoca' | |||
|
60 | 61 | .map_err(|e| (e, rev.as_ref()))?; |
|
61 | 62 | display_files(invocation.ui, repo, files.iter()) |
|
62 | 63 | } else { |
|
63 |
// The dirstate always reflects the sparse narrowspec |
|
|
64 | // we only have sparse without narrow all is fine. | |
|
65 | // If we have narrow, then [hg files] needs to check if | |
|
66 | // the store narrowspec is in sync with the one of the dirstate, | |
|
67 | // so we can't support that without explicit code. | |
|
68 | if repo.has_narrow() { | |
|
69 | return Err(CommandError::unsupported( | |
|
70 | "rhg files is not supported in narrow clones", | |
|
71 | )); | |
|
72 | } | |
|
64 | // The dirstate always reflects the sparse narrowspec. | |
|
65 | let (narrow_matcher, narrow_warnings) = narrow::matcher(repo)?; | |
|
66 | print_narrow_sparse_warnings( | |
|
67 | &narrow_warnings, | |
|
68 | &[], | |
|
69 | invocation.ui, | |
|
70 | repo, | |
|
71 | )?; | |
|
73 | 72 | let dirstate = repo.dirstate_map()?; |
|
74 | 73 | let files_res: Result<Vec<_>, _> = |
|
75 | 74 | filter_map_results(dirstate.iter(), |(path, entry)| { |
|
76 |
Ok(if entry.tracked() |
|
|
75 | Ok(if entry.tracked() && narrow_matcher.matches(path) { | |
|
76 | Some(path) | |
|
77 | } else { | |
|
78 | None | |
|
79 | }) | |
|
77 | 80 | }) |
|
78 | 81 | .collect(); |
|
79 | 82 | |
|
80 | 83 | let mut files = files_res?; |
|
81 | 84 | files.par_sort_unstable(); |
|
82 | 85 | |
|
83 | display_files(invocation.ui, repo, files.into_iter().map(Ok)) | |
|
86 | display_files( | |
|
87 | invocation.ui, | |
|
88 | repo, | |
|
89 | files.into_iter().map::<Result<_, CommandError>, _>(Ok), | |
|
90 | ) | |
|
84 | 91 | } |
|
85 | 92 | } |
|
86 | 93 |
@@ -76,7 +76,7 b' TODO: bad error message' | |||
|
76 | 76 | [1] |
|
77 | 77 | |
|
78 | 78 | A naive implementation of [rhg files] leaks the paths that are supposed to be |
|
79 | hidden by narrow, so we just fall back to hg. | |
|
79 | hidden by narrow, so we just fall back to hg when accessing a revision. | |
|
80 | 80 | |
|
81 | 81 | $ $NO_FALLBACK rhg files -r "$tip" |
|
82 | 82 | unsupported feature: rhg files -r <rev> is not supported in narrow clones |
@@ -85,6 +85,15 b' hidden by narrow, so we just fall back t' | |||
|
85 | 85 | dir1/x |
|
86 | 86 | dir1/y |
|
87 | 87 | |
|
88 | The working copy version works with narrow correctly | |
|
89 | ||
|
90 | $ $NO_FALLBACK rhg files | |
|
91 | dir1/x | |
|
92 | dir1/y | |
|
93 | $ "$real_hg" files | |
|
94 | dir1/x | |
|
95 | dir1/y | |
|
96 | ||
|
88 | 97 | Hg status needs to do some filtering based on narrow spec |
|
89 | 98 | |
|
90 | 99 | $ mkdir dir2 |
General Comments 0
You need to be logged in to leave comments.
Login now