rust/hg-core/src/filepatterns.rs
changeset 50695 1c31b343e514
parent 49930 e98fd81bb151
child 50857 796b5d6693a4
--- a/rust/hg-core/src/filepatterns.rs	Sun Jun 18 00:09:39 2023 +0200
+++ b/rust/hg-core/src/filepatterns.rs	Mon Jun 12 16:51:08 2023 +0200
@@ -50,6 +50,8 @@
     Glob,
     /// a path relative to repository root, which is matched recursively
     Path,
+    /// a single exact path relative to repository root
+    FilePath,
     /// A path relative to cwd
     RelPath,
     /// an unrooted glob (*.rs matches Rust files in all dirs)
@@ -157,6 +159,7 @@
     match kind {
         b"re:" => Ok(PatternSyntax::Regexp),
         b"path:" => Ok(PatternSyntax::Path),
+        b"filepath:" => Ok(PatternSyntax::FilePath),
         b"relpath:" => Ok(PatternSyntax::RelPath),
         b"rootfilesin:" => Ok(PatternSyntax::RootFiles),
         b"relglob:" => Ok(PatternSyntax::RelGlob),
@@ -252,7 +255,8 @@
         }
         PatternSyntax::Include
         | PatternSyntax::SubInclude
-        | PatternSyntax::ExpandedSubInclude(_) => unreachable!(),
+        | PatternSyntax::ExpandedSubInclude(_)
+        | PatternSyntax::FilePath => unreachable!(),
     }
 }
 
@@ -319,9 +323,9 @@
         }
         _ => pattern.to_owned(),
     };
-    if *syntax == PatternSyntax::RootGlob
-        && !pattern.iter().any(|b| GLOB_SPECIAL_CHARACTERS.contains(b))
-    {
+    let is_simple_rootglob = *syntax == PatternSyntax::RootGlob
+        && !pattern.iter().any(|b| GLOB_SPECIAL_CHARACTERS.contains(b));
+    if is_simple_rootglob || syntax == &PatternSyntax::FilePath {
         Ok(None)
     } else {
         let mut entry = entry.clone();