diff tests/test-fileset.t @ 35741:73432eee0ac4

fileset: add kind:pat operator ":" isn't taken as a symbol character but an infix operator so we can write e.g. "path:'foo bar'" as well as "'path:foo bar'". An invalid pattern kind is rejected in the former form as we know a kind is specified explicitly. The binding strength is copied from "x:y" range operator of revset. Perhaps it can be adjusted later if we want to parse "foo:bar()" as "(foo:bar)()", not "foo:(bar())". We can also add "kind:" postfix operator if we want. One possible confusion is that the scope of the leading "set:" vs "kind:pat" operator. The former is consumed by a matcher so applies to the whole fileset expression: $ hg files 'set:foo() or kind:bar or baz' ^^^^^^^^^^^^^^^^^^^^^^^^ Whereas the scope of kind:pat operator is narrow: $ hg files 'set:foo() or kind:bar or baz' ^^^
author Yuya Nishihara <yuya@tcha.org>
date Sun, 14 Jan 2018 13:29:15 +0900
parents 41ef02ba329b
children 7b2b82f891bf
line wrap: on
line diff
--- a/tests/test-fileset.t	Sun Jan 14 13:33:56 2018 +0900
+++ b/tests/test-fileset.t	Sun Jan 14 13:29:15 2018 +0900
@@ -27,6 +27,24 @@
   (string 're:a\\d')
   a1
   a2
+  $ fileset -v '!re:"a\d"'
+  (not
+    (kindpat
+      (symbol 're')
+      (string 'a\\d')))
+  b1
+  b2
+  $ fileset -v 'path:a1 or glob:b?'
+  (or
+    (kindpat
+      (symbol 'path')
+      (symbol 'a1'))
+    (kindpat
+      (symbol 'glob')
+      (symbol 'b?')))
+  a1
+  b1
+  b2
   $ fileset -v 'a1 or a2'
   (or
     (symbol 'a1')
@@ -80,6 +98,22 @@
   hg: parse error: can't use negate operator in this context
   [255]
 
+  $ fileset '"path":.'
+  hg: parse error: not a symbol
+  [255]
+  $ fileset 'path:foo bar'
+  hg: parse error at 9: invalid token
+  [255]
+  $ fileset 'foo:bar:baz'
+  hg: parse error: not a symbol
+  [255]
+  $ fileset 'foo:bar()'
+  hg: parse error: pattern must be a string
+  [255]
+  $ fileset 'foo:bar'
+  hg: parse error: invalid pattern kind: foo
+  [255]
+
 Test files status
 
   $ rm a1
@@ -346,6 +380,9 @@
   $ fileset -r4 'subrepo("re:su.*")'
   sub
   sub2
+  $ fileset -r4 'subrepo(re:su.*)'
+  sub
+  sub2
   $ fileset -r4 'subrepo("sub")'
   sub
   $ fileset -r4 'b2 or c1'