From patchwork Sun Jul 21 06:56:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [3,of,6] hgignore: add escape syntax test for glob patterns From: Yuya Nishihara X-Patchwork-Id: 40988 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sun, 21 Jul 2019 15:56:12 +0900 # HG changeset patch # User Yuya Nishihara # Date 1563684509 -32400 # Sun Jul 21 13:48:29 2019 +0900 # Node ID aa1e9070fdec903532d9e41e944dedca48cac548 # Parent ffd98e7af307aed4765a0fefd59d5a1a8f49850a 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(). diff --git a/tests/test-hgignore.t b/tests/test-hgignore.t --- a/tests/test-hgignore.t +++ b/tests/test-hgignore.t @@ -90,10 +90,11 @@ For icasefs, inexact matches also work, 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 @@ Ensure that comments work: $ 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: