changeset 42633:f78f305454fd

hgignore: add escape syntax test for glob patterns The last example, [\#], is what the rust implementation fails to parse. The other escapes can be removed by regexp engine or _globre().
author Yuya Nishihara <yuya@tcha.org>
date Sun, 21 Jul 2019 13:48:29 +0900
parents c67e3f966867
children 0247601869ba
files tests/test-hgignore.t
diffstat 1 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-hgignore.t	Sun Jul 21 13:37:24 2019 +0900
+++ b/tests/test-hgignore.t	Sun Jul 21 13:48:29 2019 +0900
@@ -90,10 +90,11 @@
 
 Ensure that comments work:
 
-  $ touch 'foo#bar' 'quux#'
+  $ touch 'foo#bar' 'quux#' 'quu0#'
 #if no-windows
-  $ touch 'baz\wat' 'ba0\#wat' 'ba1\\wat'
+  $ touch 'baz\' 'baz\wat' 'ba0\#wat' 'ba1\\' 'ba1\\wat' 'quu0\'
 #endif
+
   $ cat <<'EOF' >> .hgignore
   > # full-line comment
   >   # whitespace-only comment line
@@ -108,9 +109,31 @@
   $ hg status
   A dir/b.o
   ? .hgignore
-  $ rm 'foo#bar' 'quux#'
+  ? quu0#
+  ? quu0\ (no-windows !)
+
+  $ cat <<'EOF' > .hgignore
+  > .*\.o
+  > syntax: glob
+  > syntax# pattern, no whitespace, then comment
+  > a.c  # pattern, then whitespace, then comment
+  > baz\\#* # (escaped) backslash, then comment
+  > ba0\\\#w* # (escaped) backslash, escaped comment character, then comment
+  > ba1\\\\#* # (escaped) backslashes, then comment
+  > foo\#b* # escaped comment character
+  > quux\## escaped comment character at end of name
+  > quu0[\#]# escaped comment character inside [...]
+  > EOF
+  $ hg status
+  A dir/b.o
+  ? .hgignore
+  ? ba1\\wat (no-windows !)
+  ? baz\wat (no-windows !)
+  ? quu0\ (no-windows !)
+
+  $ rm 'foo#bar' 'quux#' 'quu0#'
 #if no-windows
-  $ rm 'baz\wat' 'ba0\#wat' 'ba1\\wat'
+  $ rm 'baz\' 'baz\wat' 'ba0\#wat' 'ba1\\' 'ba1\\wat' 'quu0\'
 #endif
 
 Check that '^\.' does not ignore the root directory: