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