306
306
def is_ignored(self, filename):
307
"""Check whether the filename matches an ignore pattern.
307
r"""Check whether the filename matches an ignore pattern.
309
Patterns containing '/' need to match the whole path; others
310
match against only the last component.
309
Patterns containing '/' or '\' need to match the whole path;
310
others match against only the last component.
312
312
If the file is ignored, returns the pattern which caused it to
313
313
be ignored, otherwise None. So this can simply be used as a
314
314
boolean if desired."""
316
## TODO: Use '**' to match directories, and other extended globbing stuff from cvs/rsync.
316
# TODO: Use '**' to match directories, and other extended
317
# globbing stuff from cvs/rsync.
319
# XXX: fnmatch is actually not quite what we want: it's only
320
# approximately the same as real Unix fnmatch, and doesn't
321
# treat dotfiles correctly and allows * to match /.
322
# Eventually it should be replaced with something more
318
325
for pat in self.get_ignore_list():
320
# as a special case, you can put ./ at the start of a pattern;
321
# this is good to match in the top-level only;
326
if '/' in pat or '\\' in pat:
328
# as a special case, you can put ./ at the start of a
329
# pattern; this is good to match in the top-level
332
if (pat[:2] == './') or (pat[:2] == '.\\'):