~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: mbp at sourcefrog
  • Date: 2005-03-09 04:15:02 UTC
  • Revision ID: mbp@sourcefrog.net-20050309041501-c840e09071de3b67
match ignore patterns against only the last path component
unless a path is given

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
 
259
259
 
260
260
    def is_ignored(self, filename):
261
 
        """Check whether the filename matches an ignore pattern."""
 
261
        """Check whether the filename matches an ignore pattern.
 
262
 
 
263
        Patterns containing '/' need to match the whole path; others
 
264
        match against only the last component."""
262
265
        ## TODO: Take them from a file, not hardcoded
263
266
        ## TODO: Use extended zsh-style globs maybe?
264
267
        ## TODO: Use '**' to match directories?
265
 
        ## TODO: Patterns without / should match in subdirectories?
266
 
        for i in bzrlib.DEFAULT_IGNORE:
267
 
            if fnmatch.fnmatchcase(filename, i):
268
 
                return True
 
268
        for pat in bzrlib.DEFAULT_IGNORE:
 
269
            if '/' in pat:
 
270
                if fnmatch.fnmatchcase(filename, pat):
 
271
                    return True
 
272
            else:
 
273
                if fnmatch.fnmatchcase(splitpath(filename)[-1], pat):
 
274
                    return True
269
275
        return False
270
276
        
271
277