rhg: fallback to slow path on invalid patterns in hgignore stable
authorArseniy Alekseyev <aalekseyev@janestreet.com>
Mon, 31 Oct 2022 16:15:54 +0000
branchstable
changeset 49539 8076298b795a
parent 49538 b51e5c2ab5fd
child 49540 bc2ecf08ae04
rhg: fallback to slow path on invalid patterns in hgignore
rust/rhg/src/error.rs
tests/test-hgignore.t
--- a/rust/rhg/src/error.rs	Mon Oct 31 16:15:30 2022 +0000
+++ b/rust/rhg/src/error.rs	Mon Oct 31 16:15:54 2022 +0000
@@ -221,7 +221,12 @@
 
 impl From<StatusError> for CommandError {
     fn from(error: StatusError) -> Self {
-        CommandError::abort(format!("{}", error))
+        match error {
+            StatusError::Pattern(_) => {
+                CommandError::unsupported(format!("{}", error))
+            }
+            _ => CommandError::abort(format!("{}", error)),
+        }
     }
 }
 
--- a/tests/test-hgignore.t	Mon Oct 31 16:15:30 2022 +0000
+++ b/tests/test-hgignore.t	Mon Oct 31 16:15:54 2022 +0000
@@ -59,36 +59,24 @@
   ? syntax
 
   $ echo "*.o" > .hgignore
-#if no-rhg
   $ hg status
   abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob)
   [255]
-#endif
-#if rhg
-  $ hg status
-  Unsupported syntax regex parse error:
-      ^(?:*.o)
-          ^
-  error: repetition operator missing expression
-  [255]
-#endif
 
   $ echo 're:^(?!a).*\.o$' > .hgignore
-#if no-rhg
   $ hg status
   A dir/b.o
   ? .hgignore
   ? a.c
   ? a.o
   ? syntax
-#endif
 #if rhg
-  $ hg status
-  Unsupported syntax regex parse error:
+  $ hg status --config rhg.on-unsupported=abort
+  unsupported feature: Unsupported syntax regex parse error:
       ^(?:^(?!a).*\.o$)
            ^^^
   error: look-around, including look-ahead and look-behind, is not supported
-  [255]
+  [252]
 #endif
 
 Ensure given files are relative to cwd