Show More
@@ -1223,7 +1223,12 b' def _regex(kind, pat, globsuffix):' | |||||
1223 | # Anything after the pattern must be a non-directory. |
|
1223 | # Anything after the pattern must be a non-directory. | |
1224 | return escaped + '[^/]+$' |
|
1224 | return escaped + '[^/]+$' | |
1225 | if kind == 'relglob': |
|
1225 | if kind == 'relglob': | |
1226 | return '(?:|.*/)' + _globre(pat) + globsuffix |
|
1226 | globre = _globre(pat) | |
|
1227 | if globre.startswith('[^/]*'): | |||
|
1228 | # When pat has the form *XYZ (common), make the returned regex more | |||
|
1229 | # legible by returning the regex for **XYZ instead of **/*XYZ. | |||
|
1230 | return '.*' + globre[len('[^/]*'):] + globsuffix | |||
|
1231 | return '(?:|.*/)' + globre + globsuffix | |||
1227 | if kind == 'relre': |
|
1232 | if kind == 'relre': | |
1228 | if pat.startswith('^'): |
|
1233 | if pat.startswith('^'): | |
1229 | return pat |
|
1234 | return pat |
@@ -185,14 +185,22 b' fn _build_single_regex(' | |||||
185 | res.extend(b"[^/]+$"); |
|
185 | res.extend(b"[^/]+$"); | |
186 | res |
|
186 | res | |
187 | } |
|
187 | } | |
|
188 | PatternSyntax::RelGlob => { | |||
|
189 | let mut res: Vec<u8> = vec![]; | |||
|
190 | let glob_re = glob_to_re(pattern); | |||
|
191 | if let Some(rest) = glob_re.drop_prefix(b"[^/]*") { | |||
|
192 | res.extend(b".*"); | |||
|
193 | res.extend(rest); | |||
|
194 | } else { | |||
|
195 | res.extend(b"(?:|.*/)"); | |||
|
196 | res.extend(glob_re); | |||
|
197 | } | |||
|
198 | res.extend(globsuffix.iter()); | |||
|
199 | res | |||
|
200 | } | |||
188 | PatternSyntax::Glob |
|
201 | PatternSyntax::Glob | |
189 | | PatternSyntax::RelGlob |
|
|||
190 | | PatternSyntax::RootGlob => { |
|
202 | | PatternSyntax::RootGlob => { | |
191 | let mut res: Vec<u8> = vec![]; |
|
203 | let mut res: Vec<u8> = vec![]; | |
192 | if syntax == PatternSyntax::RelGlob { |
|
|||
193 | res.extend(b"(?:|.*/)"); |
|
|||
194 | } |
|
|||
195 |
|
||||
196 | res.extend(glob_to_re(pattern)); |
|
204 | res.extend(glob_to_re(pattern)); | |
197 | res.extend(globsuffix.iter()); |
|
205 | res.extend(globsuffix.iter()); | |
198 | res |
|
206 | res |
@@ -177,7 +177,7 b' Test relative ignore path (issue4473):' | |||||
177 | ? a.c |
|
177 | ? a.c | |
178 | ? syntax |
|
178 | ? syntax | |
179 | $ hg debugignore |
|
179 | $ hg debugignore | |
180 |
<includematcher includes=' |
|
180 | <includematcher includes='.*\\.o(?:/|$)'> | |
181 |
|
181 | |||
182 | $ cd .. |
|
182 | $ cd .. | |
183 | $ echo > .hg/testhgignorerel |
|
183 | $ echo > .hg/testhgignorerel | |
@@ -224,7 +224,7 b' Test relative ignore path (issue4473):' | |||||
224 | A b.o |
|
224 | A b.o | |
225 |
|
225 | |||
226 | $ hg debugignore |
|
226 | $ hg debugignore | |
227 |
<includematcher includes=' |
|
227 | <includematcher includes='.*(?:/|$)'> | |
228 |
|
228 | |||
229 | $ hg debugignore b.o |
|
229 | $ hg debugignore b.o | |
230 | b.o is ignored |
|
230 | b.o is ignored |
@@ -100,7 +100,7 b'' | |||||
100 | f mammals/skunk skunk |
|
100 | f mammals/skunk skunk | |
101 | $ hg debugwalk -v -I 'relglob:*k' |
|
101 | $ hg debugwalk -v -I 'relglob:*k' | |
102 | * matcher: |
|
102 | * matcher: | |
103 |
<includematcher includes=' |
|
103 | <includematcher includes='.*k(?:/|$)'> | |
104 | f beans/black ../beans/black |
|
104 | f beans/black ../beans/black | |
105 | f fenugreek ../fenugreek |
|
105 | f fenugreek ../fenugreek | |
106 | f mammals/skunk skunk |
|
106 | f mammals/skunk skunk | |
@@ -108,7 +108,7 b'' | |||||
108 | * matcher: |
|
108 | * matcher: | |
109 | <intersectionmatcher |
|
109 | <intersectionmatcher | |
110 | m1=<patternmatcher patterns='mammals(?:/|$)'>, |
|
110 | m1=<patternmatcher patterns='mammals(?:/|$)'>, | |
111 |
m2=<includematcher includes=' |
|
111 | m2=<includematcher includes='.*k(?:/|$)'>> | |
112 | f mammals/skunk skunk |
|
112 | f mammals/skunk skunk | |
113 | $ hg debugwalk -v -I 're:.*k$' |
|
113 | $ hg debugwalk -v -I 're:.*k$' | |
114 | * matcher: |
|
114 | * matcher: |
General Comments 0
You need to be logged in to leave comments.
Login now