Show More
@@ -79,11 +79,11 b' class match(object):' | |||
|
79 | 79 | |
|
80 | 80 | matchfns = [] |
|
81 | 81 | if include: |
|
82 | kindpats = _normalize(include, 'glob', root, cwd, auditor) | |
|
82 | kindpats = self._normalize(include, 'glob', root, cwd, auditor) | |
|
83 | 83 | self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)') |
|
84 | 84 | matchfns.append(im) |
|
85 | 85 | if exclude: |
|
86 | kindpats = _normalize(exclude, 'glob', root, cwd, auditor) | |
|
86 | kindpats = self._normalize(exclude, 'glob', root, cwd, auditor) | |
|
87 | 87 | self.excludepat, em = _buildmatch(ctx, kindpats, '(?:/|$)') |
|
88 | 88 | matchfns.append(lambda f: not em(f)) |
|
89 | 89 | if exact: |
@@ -93,7 +93,7 b' class match(object):' | |||
|
93 | 93 | self._files = list(patterns) |
|
94 | 94 | matchfns.append(self.exact) |
|
95 | 95 | elif patterns: |
|
96 | kindpats = _normalize(patterns, default, root, cwd, auditor) | |
|
96 | kindpats = self._normalize(patterns, default, root, cwd, auditor) | |
|
97 | 97 | if not _kindpatsalwaysmatch(kindpats): |
|
98 | 98 | self._files = _roots(kindpats) |
|
99 | 99 | self._anypats = self._anypats or _anypats(kindpats) |
@@ -189,6 +189,31 b' class match(object):' | |||
|
189 | 189 | def isexact(self): |
|
190 | 190 | return self.matchfn == self.exact |
|
191 | 191 | |
|
192 | def _normalize(self, patterns, default, root, cwd, auditor): | |
|
193 | '''Convert 'kind:pat' from the patterns list to tuples with kind and | |
|
194 | normalized and rooted patterns and with listfiles expanded.''' | |
|
195 | kindpats = [] | |
|
196 | for kind, pat in [_patsplit(p, default) for p in patterns]: | |
|
197 | if kind in ('glob', 'relpath'): | |
|
198 | pat = pathutil.canonpath(root, cwd, pat, auditor) | |
|
199 | elif kind in ('relglob', 'path'): | |
|
200 | pat = util.normpath(pat) | |
|
201 | elif kind in ('listfile', 'listfile0'): | |
|
202 | try: | |
|
203 | files = util.readfile(pat) | |
|
204 | if kind == 'listfile0': | |
|
205 | files = files.split('\0') | |
|
206 | else: | |
|
207 | files = files.splitlines() | |
|
208 | files = [f for f in files if f] | |
|
209 | except EnvironmentError: | |
|
210 | raise util.Abort(_("unable to read file list (%s)") % pat) | |
|
211 | kindpats += self._normalize(files, default, root, cwd, auditor) | |
|
212 | continue | |
|
213 | # else: re or relre - which cannot be normalized | |
|
214 | kindpats.append((kind, pat)) | |
|
215 | return kindpats | |
|
216 | ||
|
192 | 217 | def exact(root, cwd, files): |
|
193 | 218 | return match(root, cwd, files, exact=True) |
|
194 | 219 | |
@@ -398,31 +423,6 b' def _buildregexmatch(kindpats, globsuffi' | |||
|
398 | 423 | raise util.Abort(_("invalid pattern (%s): %s") % (k, p)) |
|
399 | 424 | raise util.Abort(_("invalid pattern")) |
|
400 | 425 | |
|
401 | def _normalize(patterns, default, root, cwd, auditor): | |
|
402 | '''Convert 'kind:pat' from the patterns list to tuples with kind and | |
|
403 | normalized and rooted patterns and with listfiles expanded.''' | |
|
404 | kindpats = [] | |
|
405 | for kind, pat in [_patsplit(p, default) for p in patterns]: | |
|
406 | if kind in ('glob', 'relpath'): | |
|
407 | pat = pathutil.canonpath(root, cwd, pat, auditor) | |
|
408 | elif kind in ('relglob', 'path'): | |
|
409 | pat = util.normpath(pat) | |
|
410 | elif kind in ('listfile', 'listfile0'): | |
|
411 | try: | |
|
412 | files = util.readfile(pat) | |
|
413 | if kind == 'listfile0': | |
|
414 | files = files.split('\0') | |
|
415 | else: | |
|
416 | files = files.splitlines() | |
|
417 | files = [f for f in files if f] | |
|
418 | except EnvironmentError: | |
|
419 | raise util.Abort(_("unable to read file list (%s)") % pat) | |
|
420 | kindpats += _normalize(files, default, root, cwd, auditor) | |
|
421 | continue | |
|
422 | # else: re or relre - which cannot be normalized | |
|
423 | kindpats.append((kind, pat)) | |
|
424 | return kindpats | |
|
425 | ||
|
426 | 426 | def _roots(kindpats): |
|
427 | 427 | '''return roots and exact explicitly listed files from patterns |
|
428 | 428 |
General Comments 0
You need to be logged in to leave comments.
Login now