##// END OF EJS Templates
match: pass 'warn' argument to _normalize() for consistency...
Martin von Zweigbergk -
r32395:ec0311a3 default
parent child Browse files
Show More
@@ -160,7 +160,6 b' class matcher(object):'
160 self._anypats = bool(include or exclude)
160 self._anypats = bool(include or exclude)
161 self._always = False
161 self._always = False
162 self._pathrestricted = bool(include or exclude or patterns)
162 self._pathrestricted = bool(include or exclude or patterns)
163 self._warn = warn
164
163
165 # roots are directories which are recursively included/excluded.
164 # roots are directories which are recursively included/excluded.
166 self._includeroots = set()
165 self._includeroots = set()
@@ -173,7 +172,8 b' class matcher(object):'
173
172
174 matchfns = []
173 matchfns = []
175 if include:
174 if include:
176 kindpats = self._normalize(include, 'glob', root, cwd, auditor)
175 kindpats = self._normalize(include, 'glob', root, cwd, auditor,
176 warn)
177 self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)',
177 self.includepat, im = _buildmatch(ctx, kindpats, '(?:/|$)',
178 listsubrepos, root)
178 listsubrepos, root)
179 roots, dirs = _rootsanddirs(kindpats)
179 roots, dirs = _rootsanddirs(kindpats)
@@ -181,7 +181,8 b' class matcher(object):'
181 self._includedirs.update(dirs)
181 self._includedirs.update(dirs)
182 matchfns.append(im)
182 matchfns.append(im)
183 if exclude:
183 if exclude:
184 kindpats = self._normalize(exclude, 'glob', root, cwd, auditor)
184 kindpats = self._normalize(exclude, 'glob', root, cwd, auditor,
185 warn)
185 self.excludepat, em = _buildmatch(ctx, kindpats, '(?:/|$)',
186 self.excludepat, em = _buildmatch(ctx, kindpats, '(?:/|$)',
186 listsubrepos, root)
187 listsubrepos, root)
187 if not _anypats(kindpats):
188 if not _anypats(kindpats):
@@ -199,7 +200,8 b' class matcher(object):'
199 self._files = list(patterns)
200 self._files = list(patterns)
200 matchfns.append(self.exact)
201 matchfns.append(self.exact)
201 elif patterns:
202 elif patterns:
202 kindpats = self._normalize(patterns, default, root, cwd, auditor)
203 kindpats = self._normalize(patterns, default, root, cwd, auditor,
204 warn)
203 if not _kindpatsalwaysmatch(kindpats):
205 if not _kindpatsalwaysmatch(kindpats):
204 self._files = _explicitfiles(kindpats)
206 self._files = _explicitfiles(kindpats)
205 self._anypats = self._anypats or _anypats(kindpats)
207 self._anypats = self._anypats or _anypats(kindpats)
@@ -322,7 +324,7 b' class matcher(object):'
322 def prefix(self):
324 def prefix(self):
323 return not self.always() and not self.isexact() and not self.anypats()
325 return not self.always() and not self.isexact() and not self.anypats()
324
326
325 def _normalize(self, patterns, default, root, cwd, auditor):
327 def _normalize(self, patterns, default, root, cwd, auditor, warn):
326 '''Convert 'kind:pat' from the patterns list to tuples with kind and
328 '''Convert 'kind:pat' from the patterns list to tuples with kind and
327 normalized and rooted patterns and with listfiles expanded.'''
329 normalized and rooted patterns and with listfiles expanded.'''
328 kindpats = []
330 kindpats = []
@@ -342,22 +344,23 b' class matcher(object):'
342 except EnvironmentError:
344 except EnvironmentError:
343 raise error.Abort(_("unable to read file list (%s)") % pat)
345 raise error.Abort(_("unable to read file list (%s)") % pat)
344 for k, p, source in self._normalize(files, default, root, cwd,
346 for k, p, source in self._normalize(files, default, root, cwd,
345 auditor):
347 auditor, warn):
346 kindpats.append((k, p, pat))
348 kindpats.append((k, p, pat))
347 continue
349 continue
348 elif kind == 'include':
350 elif kind == 'include':
349 try:
351 try:
350 fullpath = os.path.join(root, util.localpath(pat))
352 fullpath = os.path.join(root, util.localpath(pat))
351 includepats = readpatternfile(fullpath, self._warn)
353 includepats = readpatternfile(fullpath, warn)
352 for k, p, source in self._normalize(includepats, default,
354 for k, p, source in self._normalize(includepats, default,
353 root, cwd, auditor):
355 root, cwd, auditor,
356 warn):
354 kindpats.append((k, p, source or pat))
357 kindpats.append((k, p, source or pat))
355 except error.Abort as inst:
358 except error.Abort as inst:
356 raise error.Abort('%s: %s' % (pat, inst[0]))
359 raise error.Abort('%s: %s' % (pat, inst[0]))
357 except IOError as inst:
360 except IOError as inst:
358 if self._warn:
361 if warn:
359 self._warn(_("skipping unreadable pattern file "
362 warn(_("skipping unreadable pattern file '%s': %s\n") %
360 "'%s': %s\n") % (pat, inst.strerror))
363 (pat, inst.strerror))
361 continue
364 continue
362 # else: re or relre - which cannot be normalized
365 # else: re or relre - which cannot be normalized
363 kindpats.append((kind, pat, ''))
366 kindpats.append((kind, pat, ''))
@@ -452,9 +455,10 b' class icasefsmatcher(matcher):'
452 self._fileset = set(roots)
455 self._fileset = set(roots)
453 self._fileset.update(dirs)
456 self._fileset.update(dirs)
454
457
455 def _normalize(self, patterns, default, root, cwd, auditor):
458 def _normalize(self, patterns, default, root, cwd, auditor, warn):
456 self._kp = super(icasefsmatcher, self)._normalize(patterns, default,
459 self._kp = super(icasefsmatcher, self)._normalize(patterns, default,
457 root, cwd, auditor)
460 root, cwd, auditor,
461 warn)
458 kindpats = []
462 kindpats = []
459 for kind, pats, source in self._kp:
463 for kind, pats, source in self._kp:
460 if kind not in ('re', 'relre'): # regex can't be normalized
464 if kind not in ('re', 'relre'): # regex can't be normalized
General Comments 0
You need to be logged in to leave comments. Login now