# HG changeset patch # User Arseniy Alekseyev # Date 2023-08-10 18:00:19 # Node ID 28c0fcff24e52a5af3257be05d1bc6c1fe1f386b # Parent 9ed281bbf864f735d370ee0b76dbdc2d0fa1564b rhg: fix the bug where sparse config is interpreted as relglob instead of glob relglob apparently (in contrast with relpath) matches everywhere in the tree, whereas glob only matches at the root. The python version interprets these patterns as "glob" (see "normalize(include, b'glob', ...)" in match.py) diff --git a/rust/hg-core/src/sparse.rs b/rust/hg-core/src/sparse.rs --- a/rust/hg-core/src/sparse.rs +++ b/rust/hg-core/src/sparse.rs @@ -282,7 +282,7 @@ pub fn matcher( let (patterns, subwarnings) = parse_pattern_file_contents( &config.includes, Path::new(""), - Some(b"relglob:".as_ref()), + Some(b"glob:".as_ref()), false, )?; warnings.extend(subwarnings.into_iter().map(From::from)); @@ -292,7 +292,7 @@ pub fn matcher( let (patterns, subwarnings) = parse_pattern_file_contents( &config.excludes, Path::new(""), - Some(b"relglob:".as_ref()), + Some(b"glob:".as_ref()), false, )?; warnings.extend(subwarnings.into_iter().map(From::from)); diff --git a/tests/test-sparse.t b/tests/test-sparse.t --- a/tests/test-sparse.t +++ b/tests/test-sparse.t @@ -21,6 +21,29 @@ test sparse Verify basic --include $ hg up -q 0 + +Test that sparse pattern by default is interpreted as "glob:", and is interpreted relative to the root. + + $ hg debugsparse --reset + $ hg debugsparse -X 'foo*bar' + $ cat .hg/sparse + [exclude] + foo*bar + + $ mk() { mkdir -p "$1"; touch "$1"/"$2"; } + $ mk 'foo' bar + $ mk 'foo-bar' x + $ mk 'unanchoredfoo-bar' x + $ mk 'foo*bar' x + $ mk 'dir/foo-bar' x + $ hg status --config rhg.on-unsupported=abort + ? dir/foo-bar/x + ? foo/bar + ? unanchoredfoo-bar/x + $ hg clean -a --no-confirm + $ rm -r foo*bar + $ hg debugsparse --reset + $ hg debugsparse --include 'hide' $ ls -A .hg