# HG changeset patch # User Raphaël Gomès # Date 2023-01-09 16:48:54 # Node ID c8ef85ace21617496fdfc5667c644105567b6d27 # Parent 58074252db3c5d36f5674db9861bbbbeeb1fce36 rust-narrow: fix loop that never loops This was caught by `clippy`. I guess the narrow tests leave something to be desired, since this previously only checked the first valid pattern. diff --git a/rust/hg-core/src/narrow.rs b/rust/hg-core/src/narrow.rs --- a/rust/hg-core/src/narrow.rs +++ b/rust/hg-core/src/narrow.rs @@ -100,12 +100,12 @@ fn validate_patterns(patterns: &[u8]) -> } for prefix in VALID_PREFIXES.iter() { if pattern.starts_with(prefix.as_bytes()) { - break; + return Ok(()); } - return Err(SparseConfigError::InvalidNarrowPrefix( - pattern.to_owned(), - )); } + return Err(SparseConfigError::InvalidNarrowPrefix( + pattern.to_owned(), + )); } Ok(()) } diff --git a/tests/test-narrow-clone.t b/tests/test-narrow-clone.t --- a/tests/test-narrow-clone.t +++ b/tests/test-narrow-clone.t @@ -28,6 +28,18 @@ Only path: and rootfilesin: pattern pref (narrow patterns must begin with one of the following: path:, rootfilesin:) [255] +rootfilesin: patterns work + + $ hg clone --narrow ssh://user@dummy/master rootfilesin --noupdate --include 'rootfilesin:dir' + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + new changesets 26ce255d5b5d + $ hg tracked -R rootfilesin + I rootfilesin:dir + narrow clone a file, f10 $ hg clone --narrow ssh://user@dummy/master narrow --noupdate --include "dir/src/f10"