changeset 49955:c3a76efd0b1c stable

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.
author Raphaël Gomès <rgomes@octobus.net>
date Mon, 09 Jan 2023 17:48:54 +0100
parents 194e654815e6
children 566f7dd563c1
files rust/hg-core/src/narrow.rs tests/test-narrow-clone.t
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/narrow.rs	Wed Jan 25 19:37:06 2023 +0400
+++ b/rust/hg-core/src/narrow.rs	Mon Jan 09 17:48:54 2023 +0100
@@ -100,12 +100,12 @@
         }
         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(())
 }
--- a/tests/test-narrow-clone.t	Wed Jan 25 19:37:06 2023 +0400
+++ b/tests/test-narrow-clone.t	Mon Jan 09 17:48:54 2023 +0100
@@ -28,6 +28,18 @@
   (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"