Mercurial > public > mercurial-scm > hg
changeset 52740:7405f8a67611
rhg: fix status --rev --rev sparse bug
This fixes the bug discovered in f0c439952ecb6579ee89abee84fae5587f5dda66.
The bug was introduced in 136e74c2bf8f917cf963dc1b594b6a90f8e5f627.
author | Mitchell Kember <mkember@janestreet.com> |
---|---|
date | Tue, 04 Feb 2025 14:02:20 -0500 |
parents | f0c439952ecb |
children | 5c48fd4c0e68 |
files | rust/rhg/src/commands/status.rs tests/test-sparse.t |
diffstat | 2 files changed, 14 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/rhg/src/commands/status.rs Tue Feb 04 13:39:28 2025 -0500 +++ b/rust/rhg/src/commands/status.rs Tue Feb 04 14:02:20 2025 -0500 @@ -462,14 +462,18 @@ let (narrow_matcher, narrow_warnings) = narrow::matcher(repo)?; let (sparse_matcher, sparse_warnings) = sparse::matcher(repo)?; - let matcher = match (repo.has_narrow(), repo.has_sparse()) { - (true, true) => { - Box::new(IntersectionMatcher::new(narrow_matcher, sparse_matcher)) - } - (true, false) => narrow_matcher, - (false, true) => sparse_matcher, - (false, false) => Box::new(AlwaysMatcher), - }; + // Sparse is only applicable for the working copy, not history. + let sparse_is_applicable = revpair.is_none() && change.is_none(); + let matcher = + match (repo.has_narrow(), repo.has_sparse() && sparse_is_applicable) { + (true, true) => Box::new(IntersectionMatcher::new( + narrow_matcher, + sparse_matcher, + )), + (true, false) => narrow_matcher, + (false, true) => sparse_matcher, + (false, false) => Box::new(AlwaysMatcher), + }; let matcher = match args.get_many::<std::ffi::OsString>("file") { None => matcher, Some(files) => {
--- a/tests/test-sparse.t Tue Feb 04 13:39:28 2025 -0500 +++ b/tests/test-sparse.t Tue Feb 04 14:02:20 2025 -0500 @@ -54,10 +54,10 @@ Test that status --rev --rev and --change ignore sparse rules. $ hg status --rev null --rev 0 A hide - A show (no-rhg !) + A show $ hg status --change 0 A hide - A show (no-rhg !) + A show Absolute paths outside the repo should just be rejected