##// END OF EJS Templates
matcher: fix issues regex flag contained in pattern (issue6759)...
marmoute -
r50498:3eda36e9 stable
parent child Browse files
Show More
@@ -1323,6 +1323,9 def _globre(pat):
1323 1323 return res
1324 1324
1325 1325
1326 FLAG_RE = util.re.compile(b'^\(\?([aiLmsux]+)\)')
1327
1328
1326 1329 def _regex(kind, pat, globsuffix):
1327 1330 """Convert a (normalized) pattern of any kind into a
1328 1331 regular expression.
@@ -1353,6 +1356,8 def _regex(kind, pat, globsuffix):
1353 1356 if kind == b'relre':
1354 1357 if pat.startswith(b'^'):
1355 1358 return pat
1359 if FLAG_RE.match(pat):
1360 return FLAG_RE.sub(br'(?\1:.*', pat) + b')'
1356 1361 return b'.*' + pat
1357 1362 if kind in (b'glob', b'rootglob'):
1358 1363 return _globre(pat) + globsuffix
@@ -63,6 +63,50 Should display baz only:
63 63 abort: $TESTTMP/ignorerepo/.hgignore: invalid pattern (relre): *.o (glob)
64 64 [255]
65 65
66 Test relre with flags (issue6759)
67 ---------------------------------
68
69 regexp with flag is the first one
70
71 $ echo 're:(?i)\.O$' > .hgignore
72 $ echo 're:.hgignore' >> .hgignore
73 $ hg status
74 A dir/b.o
75 ? a.c
76 ? syntax
77
78 regex with flag is not the first one
79
80 $ echo 're:.hgignore' > .hgignore
81 $ echo 're:(?i)\.O$' >> .hgignore
82 $ hg status
83 A dir/b.o
84 ? a.c
85 ? syntax
86
87 flag in a pattern should affect that pattern only
88
89 $ echo 're:(?i)\.O$' > .hgignore
90 $ echo 're:.HGIGNORE' >> .hgignore
91 $ hg status
92 A dir/b.o
93 ? .hgignore (no-rust !)
94 ? .hgignore (rust missing-correct-output !)
95 ? a.c
96 ? syntax
97
98 $ echo 're:.HGIGNORE' > .hgignore
99 $ echo 're:(?i)\.O$' >> .hgignore
100 $ hg status
101 A dir/b.o
102 ? .hgignore
103 ? a.c
104 ? syntax
105
106
107 further testing
108 ---------------
109
66 110 $ echo 're:^(?!a).*\.o$' > .hgignore
67 111 $ hg status
68 112 A dir/b.o
General Comments 0
You need to be logged in to leave comments. Login now