~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-29 02:41:07 UTC
  • Revision ID: mbp@sourcefrog.net-20050329024107-7fd789f7ca7d64ab
Tree.is_ignored returns the pattern that matched, if any

Show diffs side-by-side

added added

removed removed

Lines of Context:
280
280
        """Check whether the filename matches an ignore pattern.
281
281
 
282
282
        Patterns containing '/' need to match the whole path; others
283
 
        match against only the last component."""
284
 
        ## TODO: Use extended zsh-style globs maybe?
285
 
        ## TODO: Use '**' to match directories?
 
283
        match against only the last component.
 
284
 
 
285
        If the file is ignored, returns the pattern which caused it to
 
286
        be ignored, otherwise None.  So this can simply be used as a
 
287
        boolean if desired."""
 
288
 
 
289
        ## TODO: Use '**' to match directories, and other extended globbing stuff from cvs/rsync.
 
290
        
286
291
        for pat in self.get_ignore_list():
287
292
            if '/' in pat:
288
293
                if fnmatch.fnmatchcase(filename, pat):
289
 
                    return True
 
294
                    return pat
290
295
            else:
291
296
                if fnmatch.fnmatchcase(splitpath(filename)[-1], pat):
292
 
                    return True
293
 
        return False
 
297
                    return pat
 
298
        return None
294
299
        
295
300
 
296
301